class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
require'class.upload.php';
$files = array();
foreach ($_FILES['image_field'] as $k => $l) {
foreach ($l as $i => $v) {
if (!array_key_exists($i, $files))
$files[$i] = array();
$files[$i][$k] = $v;
}
}
foreach ($files as $file) {
$handle = new Upload($file);
if ($handle->uploaded) {
$handle->Process("C:\Users\ALEX\Desktop\images");
if ($handle->processed) {
echo 'OK';
} else {
echo 'Error: ' . $handle->error;
}
} else {
echo 'Error: ' . $handle->error;
}
unset($handle);
}
This is the code that i'm using for the upload.php file When i upload an image it says Warning: Invalid argument supplied for foreach(), and it is this line of the code foreach ($l as $i => $v)
Check if your form is functioning properly. If you do a vardump() of $_FILES, what do you see? In any case, you need to make sure that your arrays are correct.Reply
This is the code that i'm using for the upload.php file
When i upload an image it says Warning: Invalid argument supplied for foreach(), and it is this line of the code foreach ($l as $i => $v)
What should i do ?