File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments