Image upload problem via theme option
-
Hello ,
I have created a custom theme option where around multiple image upload around more than 20 . It seems work properly , but now I have faced a huge problem , all image upload work except the last 3 one .
Say if I put the last 3 at the top , then they works , but then the last 3 were not working . Use wp_handle_upload to upload the images . here is the code .
if ( isset($_POST[$delete_field]) && $_POST[$delete_field]=='true' ) return ''; if ( empty($_FILES) || !isset($_FILES[$file_index]) || 0==$_FILES[$file_index]['size'] ) return $old_value; $overrides = array('test_form' => false); $file = wp_handle_upload($_FILES[$file_index], $overrides); if ( isset($file['error']) ) wp_die( $file['error'] ); $url = $file['url']; $type = $file['type']; $file = $file['file']; $filename = basename($file); $object = array( 'post_title' => $filename, 'post_content' => $url, 'post_mime_type' => $type, 'guid' => $url ); $id = wp_insert_attachment($object, $file); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); do_action('wp_create_file_in_uploads', $file, $id); // For replication return esc_url($url);
Can anyone give me a solution ASAP . this is very urgent .
Thanks in advance .
- The topic ‘Image upload problem via theme option’ is closed to new replies.