Here is what I have so far, I apologize for the length but this gives you the complete picture:
if(count($_FILES['file']['name']))
{
foreach ($_FILES['file']['name'] as $key => $file)
{
$add="../uploads/photogallery/".time().'_'.$file;
$storefile = time().'_'.$file;
echo $storefile; // THIS WORKS
if(move_uploaded_file ($_FILES['file']['tmp_name'][$key],$add))
{
// CODE IS NOT GETTING INTO THIS AREA,
//database insert here
//mysql_query ($query);
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_added">';
}
else
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_not_added">';
}
///////// Start the thumbnail generation//////////////
$n_width=150; // Fix the width of the thumb nail images
$n_height=150; // Fix the height of the thumb nail imaage
$tsrc="../uploads/photogallery/thumbnail/".time().'_'.$file;
if (!($_FILES['file']['type'][$key] =="image/pjpeg" || $_FILES['file']['type'][$key] == "image/gif" || $_FILES['file']['type'][$key] == "image/png") || ($_FILES["file"]["type"][$key] == "image/jpeg") && ($_FILES["file"]["size"][$key] < 2097152))
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$_FILES['file']['type'][$key] =="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif"))
{
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg"))
{
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
elseif (function_exists("imagepng"))
{
Header("Content-type: image/png");
ImagePNG($newimage,$tsrc);
}
}
////////////// starting of JPG thumb nail creation//////////
if ($_FILES['file']['type'][$key] == "image/pjpeg")
{
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
}
if ($_FILES['file']['type'][$key] == "image/png")
{
$im=ImageCreateFromPNG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImagePNG($newimage,$tsrc);
}
}
}
else
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
}
And here is the HTML portion of the form:
<input class="input" name="file[]" type="file" id="file" multiple=""/>
Yes the form has the correct enctype. See my comments in the code above where it says THIS WORKS and CODE IS NOT..etc. That is where my issue is. It's getting inside the for each loop part since I can echo $storefile and get the correct filename with the time stamp, but it won't get into the if (move_uploaded_..) portion and skips to the echo photo requirements not met portion.
Any help would be greatly appreciated. I am not getting any PHP or mysql errors.
$_FILES['file']['tmp_name']"file" is a function in PHP, and you should always enclose textual indexes in quotes. Perhaps PHP runs the "file" function and uses the return value as an index (not what you want)$_FILES[file][tmp_name]with$_FILES['file']['tmp_name']. Even if it doesn't help, it is good practice to do so