I don't know if this is a PHP problem or an IIS problem (assuming IIS) but on my site i'm trying to allow users to upload 'logos'. When the user hits submit, the handler gives the errors.
Notice: Undefined variable: image_name in C:\phpforms\addressbook\test2.php on line 8
Notice: Undefined variable: image in C:\phpforms\addressbook\test2.php on line 11
Notice: Undefined variable: image in C:\phpforms\addressbook\test2.php on line 11
I copied the EXACT code to another server running Apache and it works like a charm. I'm affraid somethings setup wrong on my IIS server but i cannot figure out what. However I could be my code so i'll list it below. Any suggestions or comments would be greatly apreciated. Thanks.
The following code is test.php
<?php
print("
<form action=\"test2.php\" method=\"post\" ENCTYPE=\"multipart/form-data\">
<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"10000\">
<input type=\"file\" size=\"60\" name=\"image\">
<input NAME=\"upload\" type=\"submit\" value=\"Upload New Logo\">
</form>
");
?>
The follwing code is test2.php
<?php
if(isset($upload)){
$filepath = "/tempimages";
$dirname = "$filepath/gabe";
@mkdir($dirname,0777);
$uploadpath = "$dirname/$image_name";
$dest = "";
if ( ($image != 'none') && ($image != '' )) {
$imagesize = getimagesize($image);
switch ( $imagesize[2] ) {
case 0:
echo '<font> Image is unknown </font>';
break;
case 1:
echo '<font> Image is a GIF </font>';
$dest = $uploadpath.uniqid('img').'.gif';
break;
case 2:
echo '<font> Image is a JPG </font>';
$dest = $uploadpath.uniqid('img').'.jpg';
break;
case 3:
echo '<font> Image is a PNG </font>';
$dest = $uploadpath.uniqid('img').'.png';
break;
}
if ( $dest != '' ) {
if ( copy($image, $uploadpath) ) {
echo '<font>File successfully stored.</font><BR>';
unlink($image);
} else {
echo '<font>File could not be stored.<BR></font>';
}
}
} else {
echo '<font>File not supplied, or file too big.</font><BR>';
}
}
?>