FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


move_uploaded_file problem





PatTheGreat42
I'm creating a website for my teacher who doesn't know anything about ye old Internet, and to make the process easier for her, I made an admin page where she could upload files to the website.

To do this, I created a form that sends the uploaded form to a script called changes.php. Part of the script is as follows:

Code:
$path = $directory."/".$FILES[newFile][name];
$temporary = $_FILES[newFile][tmp_name];
move_uploaded_file($temporary,$path);


Previously in the code, $directory had been defined as the folder in which the file should go, depending on the file type (Like .txt or .ppt, not using filetype()), and unidentified file types being shuffled into an "other" folder.

However, when I try to run the code, I get this:

Quote:
Warning: move_uploaded_file(/): failed to open stream: Is a directory in /home/patthegr/public_html/poist/changes.php on line 64

Warning: move_uploaded_file(): Unable to move '/tmp/phpeT726H' to '/' in /home/patthegr/public_html/poist/changes.php on line 64


I can't figure out what is wrong, and I'm looking for some help. I stuck pretty close to the example in PHP 5 for Dummies (Which is why I bothered defining $temporary as it's own variable), but I still can't get it to work. Any ideas?

Thanks.
Traveller
In the line where you created $path, you left the underscore between the $ and "FILES".

In addition, you missed the apostrophes around newFile, name, and tmp_name (as the indices for $_FILES). They should be $_FILES['newFile']['name'] and $_FILES['newFile']['tmp_name'].

The whole thing means that $temporary and $path do not contain the values you expect them to have, and will not work for the move_uploaded_file() function.

Along with making the above changes, it would probably be a good idea to echo the values of $temporary and $path, so you can SEE what's happening, until you actually have it working properly.
Related topics
Problem with Subdomains
Strange Fire fox problem
Logout problem (Cookie?)
How to solve this problem? Thanks
I have a problem....Mozilla Firefox
post nuke problem
anyone had this phpBB problem?
phpbb problem....
Transport yourself over the Net
Problem with my password
Pictures problem...
database problem
same problem over here...
Header("Location: PROBLEM");
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.