Hi,
I have problem with uploading images by php script.
I created a HTML form for user to input image file, and simple PHP script which accepts this file from form and prints it in the browser. My script uploads file, prints file's name, generates HTML code, but does not output image.
My PHP code is:
<?php
$tmp_file=$_FILES['userfile']['tmp_name']; //file stored on server
if (is_uploaded_file($tmp_file)) { // check if image is uploaded by client
$size = getimagesize($tmp_file); // get image dimensions
if ($size==false) {
echo 'File $tmp_name is not accessible or it is not a valid picture';
}
else {
$width = round($size[0]);
$height = round($size[1]);
echo "<br><br>File: ", $tmp_file, "<br><br>"; // print image
echo '<img scr="'.$tmp_file.'" border="0" alt="'.$tmp_file.'" width="'.$width.'" height="'.$height.'">' ;
}
}
else { // file upload failed
echo "Possible file upload attack: ";
echo "filename '". $tmp_file . "'.";
}
}
?>
The possible output is:
File: C:/Program Files/wamp/tmp\php4B.tmp
<IMG height=180 alt="C:/Program Files/wamp/tmp\php4B.tmp" width=300 border=0 scr="C:/Program Files/wamp/tmp\php4B.tmp">
Instead image, it displays default icon.
That means that image file hasn't been uploaded.
What's wrong with my program? Please help me