PHP Uploading File with EasyPHP-5.3.2i

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zaroth
Forum Newbie
Posts: 5
Joined: Sat Jun 12, 2010 8:37 pm

PHP Uploading File with EasyPHP-5.3.2i

Post by Zaroth »

How would I upload a file with "EasyPHP-5.3.2i" with modifying this code? (It's for my prof)

Code: Select all

<?php // upload.php
echo <<<_END
<html><head><title>PHP Form Upload</title></head><body>
<form method='post' action='upload.php' enctype='multipart/form-data'>
Select File: <input type='file' name='filename' size='10' />
<input type='submit' value='Upload' />
</form>
_END;

if ($_FILES)
{
	$name = $_FILES['filename']['name'];
	move_uploaded_file($_FILES['filename']['tmp_name'], $name);
	echo "Uploaded image '$name'<br /><img src='$name' />";
}

echo "</body></html>";
?>
Without modifying the example I get this for an error....

Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404
localhost
06/12/10 21:13:30
Apache/2.2.15 (Win32) PHP/5.3.2
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: PHP Uploading File with EasyPHP-5.3.2i

Post by cpetercarter »

You are trying to "move" your uploaded file to $_FILES['filename']['name'], That won't work. You need to specify the path to a location where you want to send the file (something like "uploaded_files/filename.txt").
Zaroth
Forum Newbie
Posts: 5
Joined: Sat Jun 12, 2010 8:37 pm

Re: PHP Uploading File with EasyPHP-5.3.2i

Post by Zaroth »

I'm new to PHP, I've been looking at many examples to find the proper syntax to specify the location of the uploaded file.
Example: Using this as a location C:\Program Files (x86)\EasyPHP-5.3.2i\www\lab5\upload.gif
Post Reply