I have a form that users should upload multiple images but the code doesn't run correctly. This code works perfectly but when I add foreach
to upload more images it doesn't work. it seems that $_FILES
only gets the first image. I would be grateful if you could help.
if(isset($_FILES['uploadfile']['name'])){
if(! function_exists('wp_handle_upload')){
require_once(ABSPATH.'wp-admin/includes/file.php');
}
$uploadedfile = $_FILES ['uploadfile'];
$upload_overrides = array('test_form' => false );
$movefile = wp_handle_upload($uploadedfile, $upload_overrides);
if($movefile && !isset($movefile['error'])){
echo '<a href="'.$movefile['url'].'">view the link</a>';
}else{
echo '<p>'.$movefile['error'].'</p>';
}
}