Skip to content

Commit b19fd27

Browse files
committed
Merge branch 'master' of github.com:libreform/wp-libre-form
2 parents 6173d88 + 0ef59d8 commit b19fd27

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

inc/wplf-ajax.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ function wplf_ajax_submit_handler() {
7878
$should_store_images_in_medialibrary = get_post_meta( $form->ID, '_wplf_media_library', true );
7979
$counter = 0;
8080
foreach ( $_FILES as $key => $file ) {
81+
// skip empty upload fields
82+
if ( empty( $file['tmp_name'] ) ) continue;
83+
8184
// Is this enough security wise?
8285
// Currenly only supports 1 file per input
8386
if ( $should_store_images_in_medialibrary ) {
@@ -90,11 +93,11 @@ function wplf_ajax_submit_handler() {
9093
add_post_meta( $post_id, $key . '_attachment', $attach_id );
9194
}
9295
} else {
93-
$name = 'lf_' . date( 'ymdhs' ) . '-' . $counter . '-' . sanitize_file_name( $file['name'] );
96+
$name = 'lf_' . date( 'ymdhs' ) . '-' . $counter . '-' . sanitize_file_name( $file['name'] );
9497

95-
move_uploaded_file( $file['tmp_name'], $uploads_path['path'] . '/' . $name );
96-
add_post_meta( $post_id, $key . '_attachment', $uploads_path['url'] . '/' . $name );
97-
$counter++;
98+
move_uploaded_file( $file['tmp_name'], $uploads_path['path'] . '/' . $name );
99+
add_post_meta( $post_id, $key . '_attachment', $uploads_path['url'] . '/' . $name );
100+
$counter++;
98101
}
99102
}
100103

0 commit comments

Comments
 (0)