i'm a beginner and i've created this small commenting page: http://slprogrammersheaven.zzl.org/test1/index.php. There's a link at the bottom of the page (which is currently not working) to change the background image of the webpage. When the link is clicked, a page is opened containing the controls to upload an image file. When the Submit button is pressed, upload_file.php file is called to handle the uploading job. The code should 1st upload the file and then copy it to the "upload" directory as "bg004x.jpg". The code:
- Code: Select all
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
...
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload\\" . $_FILES["file"]["bg004x.jpg"]); // Move the file
...
}
When i run this on localhost, i get below output with errors:
- Code: Select all
Notice: Undefined index: bg004x.jpg in C:\xampp\htdocs\test1\upload_file.php on line 26
Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in C:\xampp\htdocs\test1\upload_file.php on line 26
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php55A0.tmp' to 'upload\' in C:\xampp\htdocs\test1\upload_file.php on line 26
What's causing these errors?
Thanks for any help.


on 26th line