Go to the File Upload element settings.

Then go to the Data tab.

Then enable the option Add to media library.

Show legacy instructions
Add the following code to your site (see Adding custom code for help):
12 3 45 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; $files = $form->getValue('quform_1_3'); foreach ($files as $file) { $type = wp_check_filetype($file['name'], null); $attachment = array( 'post_title' => $file['name'], 'post_content' => '', 'post_mime_type' => $type['type'], 'guid' => $file['url'] ); $attachId = wp_insert_attachment($attachment, $file['path']); wp_update_attachment_metadata($attachId, wp_generate_attachment_metadata($attachId, $file['path'])); } return $result; }, 10, 2); |
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) {
require_once ABSPATH . 'wp-admin/includes/image.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
$files = $form->getValue('quform_1_3');
foreach ($files as $file) {
$type = wp_check_filetype($file['name'], null);
$attachment = array(
'post_title' => $file['name'],
'post_content' => '',
'post_mime_type' => $type['type'],
'guid' => $file['url']
);
$attachId = wp_insert_attachment($attachment, $file['path']);
wp_update_attachment_metadata($attachId, wp_generate_attachment_metadata($attachId, $file['path']));
}
return $result;
}, 10, 2);1 2 3 45 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 | function my_save_uploads_to_media_library(array $result, Quform_Form $form) { require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; $files = $form->getValue('quform_1_3'); foreach ($files as $file) { $type = wp_check_filetype($file['name'], null); $attachment = array( 'post_title' => $file['name'], 'post_content' => '', 'post_mime_type' => $type['type'], 'guid' => $file['url'] ); $attachId = wp_insert_attachment($attachment, $file['path']); wp_update_attachment_metadata($attachId, wp_generate_attachment_metadata($attachId, $file['path'])); } return $result; }add_filter('quform_post_process_1', 'my_save_uploads_to_media_library', 10, 2); |
function my_save_uploads_to_media_library(array $result, Quform_Form $form)
{
require_once ABSPATH . 'wp-admin/includes/image.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
$files = $form->getValue('quform_1_3');
foreach ($files as $file) {
$type = wp_check_filetype($file['name'], null);
$attachment = array(
'post_title' => $file['name'],
'post_content' => '',
'post_mime_type' => $type['type'],
'guid' => $file['url']
);
$attachId = wp_insert_attachment($attachment, $file['path']);
wp_update_attachment_metadata($attachId, wp_generate_attachment_metadata($attachId, $file['path']));
}
return $result;
}
add_filter('quform_post_process_1', 'my_save_uploads_to_media_library', 10, 2);