I realize others have had problems with the undefined index issue, but I can't find any answer to my particular problem in any forum, anywhere.
I have a form/script which uploads images with description for an artist site. There are 25 images available to upload (an artist profile image and 24 art images), and the images 1-19 upload just fine. All the images share exactly the same code. But when the processing script comes to image 20, it fails and I get the "undefined index" notice. Here is the processing code for image 19-20.
//There are a total of 20 other blocks of code above this one,
//and they are all the same except for the image number.
//Artimage19 Process Begin
$artimage19 = $_FILES['artimage19']['name'];
$file_size = $_FILES['artimage19']['size'];
$file_temp = $_FILES['artimage19']['tmp_name'];
$title19 = $_POST['title19'];
$disptitle19 = stripslashes($title19);
$medium19 = $_POST['medium19'];
$dim19 = $_POST['dim19'];
$price19 = $_POST['price19'];
$file_basename = substr($artimage19, 0, strripos($artimage19, '.')); // strip extention
$file_ext = substr($artimage19, strripos($artimage19, '.'));
$allowed_extensions['ext']= array('jpeg','jpg','gif','png');
if(!$allowed_extensions){
echo "Artimage19 file extension not allowed.";
}else{
$file_ext = strtolower($file_ext);
$random = rand(0000, 9999);
$new_file_name19 = $surname.$random. '.' .$file_ext;
}
if($file_size > MAX_SIZE*1024) {
echo 'ARTIMAGE19 FILE SIZE TO LARGE<BR />';
}
if(move_uploaded_file($file_temp, "$filepath/$new_file_name19")) {
//echo '<h3>Upload Successful!</h3>';
} else {
echo '<h3>ERROR IN UPLOADING ARTIMAGE19</h3>';
}
//Artimage19 Process Ends
//Artimage20 Process Begin
$artimage20 = $_FILES['artimage20']['name'];
$file_size = $_FILES['artimage20']['size'];
$file_temp = $_FILES['artimage20']['tmp_name'];
$title20 = $_POST['title20'];
$disptitle20 = stripslashes($title20);
$medium20 = $_POST['medium20'];
$dim20 = $_POST['dim20'];
$price20 = $_POST['price20'];
$file_basename = substr($artimage20, 0, strripos($artimage20, '.')); // strip extention
$file_ext = substr($artimage20, strripos($artimage20, '.'));
$allowed_extensions['ext']= array('jpeg','jpg','gif','png');
if(!$allowed_extensions){
echo "Artimage20 file extension not allowed.";
}else{
$file_ext = strtolower($file_ext);
$random = rand(0000, 9999);
$new_file_name20 = $surname.$random. '.' .$file_ext;
}
if($file_size > MAX_SIZE*1024) {
echo 'ARTIMAGE20 FILE SIZE TO LARGE<BR />';
}
if(move_uploaded_file($file_temp, "$filepath/$new_file_name20")) {
//echo '<h3>Upload Successful!</h3>';
} else {
echo '<h3>ERROR IN UPLOADING ARTIMAGE20</h3>';
}
//Artimage20 Process Ends
Artimage19 uploads just fine, but Artimage20 fails.
The $filepath is set correctly, as it uploads all previous image files.
The code for the submitting code is fine also. Here is the code that submits the data.
//The form header is below
<form action="pdregisterres.php" method="POST" enctype="multipart/form-data" onSubmit="return checkrequired(this)">
//there are 18 others above this plus one for an artist profile image
<tr><td colspan = "2"><hr></td></tr>
<tr><td align = "left">Art Image 19:</td><td align = "left"><input type = "file" name = "artimage19"></td></tr>
<tr><td align = "left">Title:</td><td align = "left"><input type = "text" name = "title19"></td></tr>
<tr><td align = "left">Medium:</td><td align = "left"><input type = "text" name = "medium19"></td></tr>
<tr><td align = "left">Dimensions:</td><td align = "left"><input type = "text" name = "dim19"></td></tr>
<tr><td align = "left">Price:</td><td align = "left"><input type = "text" name = "price19"></td></tr>
<tr><td colspan = "2"><hr></td></tr>
<tr><td align = "left">Art Image 20:</td><td align = "left"><input type = "file" name = "artimage20"></td></tr>
<tr><td align = "left">Title:</td><td align = "left"><input type = "text" name = "title20"></td></tr>
<tr><td align = "left">Medium:</td><td align = "left"><input type = "text" name = "medium20"></td></tr>
<tr><td align = "left">Dimensions:</td><td align = "left"><input type = "text" name = "dim20"></td></tr>
<tr><td align = "left">Price:</td><td align = "left"><input type = "text" name = "price20"></td></tr>
For some reason that I can't get, the form stops processing after Artimage19 and gives me this:
Notice: Undefined index: artimage20 in /home/www/artistsofeureka.info/members/pdregisterres.php on line 1046
I also get the error message: ERROR IN UPLOADING ARTIMAGE20
I get this for images 20-24.
Since the code for all image processing is exactly the same (except for image #), I can't see why it stops at #19.
These images are being uploaded to a folder on my server and a mysql db. Images up to #19 upload just fine.
Any comments, questions or helpful advice?