I have a file upload form
echo '<tr>'."\n";
echo '<td bgcolor="CCCCCC">Thumbnail</td>'."\n";
echo '<td bgcolor="CCCCCC"><label>'."\n";
echo '<input name="thumb" type="file" id="thumb" size="30" />'."\n";
echo '</label></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '<td>Video</td>'."\n";
echo '<td><label>'."\n";
echo '<input name="vid" type="file" id="vid" size="30" />'."\n";
echo '</label></td>'."\n";
echo '</tr>'."\n";
It POST's the values to this script
extract ($_POST);
function setNan ($variable){
if (!isset($variable)){
$variable = "nan";
}
}
setNan($thumb);
setNan($vid);
addslashes ($thumb);
addslashes ($vid);
// -- Upload image
if ($thumb != "nan" && $thumb != ""){
$src = $_FILES['thumb']['tmp_name'];
$tempName = explode(".", $_FILES['thumb']['name']);
$number = mysql_query("SELECT MAX(id) AS idx FROM $imageTable");
$row = mysql_fetch_assoc($number);
$numRows = $row['idx'];
if ($numRows == ""){
$numRows = "0";
}
$newName = $numRows.".".$tempName[1];
$trg = $imageUploadPath.$newName;
move_uploaded_file ($src, $trg);
$thumb = $newName;
} else {
$thumb = "nan";
}
// -- /Upload image
// -- Upload video
if ($vid != "nan" && $vid != ""){
$src = $_FILES['vid']['tmp_name'];
$tempName = explode(".", $_FILES['vid']['name']);
$number = mysql_query("SELECT MAX(id) AS idx FROM $videosTable");
$row = mysql_fetch_assoc($number);
$numRows = $row['idx'];
if ($numRows == ""){
$numRows = "0";
}
$newName = $numRows.".".$tempName[1];
$trg = $videoUploadPath.$newName;
move_uploaded_file ($src, $trg);
$vid = $newName;
} else {
$vid = "nan";
}
// -- /Upload video
If i dont specify a file its all good.
But when i do i get the following error
PHP Notice: Undefined index: thumb in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 160 PHP Notice: Undefined index: thumb in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 161 PHP Notice: Undefined offset: 1 in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 168 PHP Notice: Undefined index: vid in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 178 PHP Notice: Undefined index: vid in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 179 PHP Notice: Undefined offset: 1 in C:\Inetpub\wwwroot\yourcapecoral\wizard\listings.php on line 186
Does anyone have any idea?
All help is appriciated.
Thank you for your time
~Gabor