Hi, I have an image upload page that creates a dynamic number of file upload boxes depending on how many the user wants.
They are numbered in sequential order Image0,Image1,Image2 etc…
The user then selects files for each input box and clicks the Submit button.
On the next page i need to check each one of these file input boxes and validate them to see if they are images and of the correct size etc…
The validation is no problem, but i can’t figure out how to get the values of the input boxes. I keep track of how many were created thru a hidden input field. so i know how many files i need to validate but i cant figure out how to get the values of the file input fileds.
I tried a For loop to loop the number of times that there are fields and create a varible with the same names as the fields and try to validate them but ofcourse the variables are empty because they are new variables and not the ones i passed from the last form.
Here is my code.
[code=php]
//Image checking
For($Counter =0; $Counter < $txtNumImages; $Counter++){
//Create variable with the same name as the input fields
$Image = “$Image”.$Counter;
$TypeTest = “False”;
ereg_replace (” “, “_”, $Image_name);
If ((!empty($Image) AND $Image_type == “image/pjpeg” AND $Image_type == “image/jpeg”) OR $Image_type == “image/gif”)$TypeTest = “True”;
If (!$TypeTest) $Error .= “<img src=”../images/errorarrow.gif” border=0>Image must be in either .jpg or .gif format.<br>”;
// Check To Make Sure Image Is Of Right Dimensions //
$ImageSize = getimagesize(“$Image”);
$ImageWidth = $ImageSize[0];
$ImageHeight = $ImageSize[1];
If ($ImageWidth < 400 Or $ImageHeight < 160)$Error .= “<img src=”../images/errorarrow.gif” border=0>Image is not the correct size, it must be exactly 400×160 in size.<br>”;
If ($Error != “”){
User_Error_Message($Error);
}else{
$FullPath = “/home/httpd/html/allsites/specialeventimages/”;
Copy($Image,$FullPath.$Image_name);
If(!Copy) Error_Message(“<img src=”../images/errorarrow.gif” border=0>Unable to copy image.”);
unlink ($Image);
}
}
All the validation code works great.. i just can’t figure out how to get the values of the dynamically created input fileds on the last page.
Any help is appreciated!
Thanks!