Page 1 of 2
Help with uploading files
Posted: Sat Oct 09, 2004 9:21 am
by frankpmjr
Hi, I created a form that uploads files into my server (for CMS system) and it all seems to work well except that when after the file is uploaded, I can't find it. I used the script below to move it to what I think is the correct place but it isn't there when I check. Any insight would be appreciated
Code: Select all
move_uploaded_file($_FILESї'upload_snd']ї'tmp_name'],"..downloads/$filename");
echo'<p>The sound file has been uploaded!</p>';
Is there anyway I can verify that the file is indeed being uploaded? I tried to navigate to the tmp_name to see if it is there but that doesn't work either.
Thanks for the help.
Frank
Posted: Sat Oct 09, 2004 9:22 am
by qads
make sure that the folder you are uploading to is there, and the path is correct, try:
Code: Select all
<?php
move_uploaded_file($_FILES['upload_snd']['tmp_name'],"../downloads/$filename");
echo'<p>The sound file has been uploaded!</p>';
?>
if you are not on windows, you also need to chmod the folder to 0777.
Posted: Sat Oct 09, 2004 9:32 am
by frankpmjr
I'm on a linux machine. I hate to sound like an idiot but can you explain chmod the folder to 0777, thanks.
Posted: Sat Oct 09, 2004 9:35 am
by feyd
[google]man chmod[/google]
[php_man]chmod[/php_man]()
Posted: Sat Oct 09, 2004 9:37 am
by frankpmjr
To clarify, it is to make sure that I can write files into the folder?
Posted: Sat Oct 09, 2004 9:38 am
by feyd
write, read, and/or execute files or folders.
Posted: Sat Oct 09, 2004 9:46 am
by frankpmjr
feyd | Please use Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I did it (code is below) but it didn't make a difference. I still can't find the file.
Code: Select all
chmod ("../downloads", 0777);
$extension = explode('.',$_FILES['upload_snd']['name']);
$uid = mysql_insert_id();
$filename = $uid.'.'.$extension[1];
move_uploaded_file($_FILES['upload_snd']['tmp_name'],"../downloads/$filename");
feyd | Please use Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Sat Oct 09, 2004 9:52 am
by feyd
maybe you are missing something. Add
Code: Select all
error_reporting(E_ALL);
ini_set('display_errors', '1');
in front of your code.
also, check the return from
Code: Select all
move_uploaded_file[/php_man]() to make sure it's doing it okay...
Posted: Sat Oct 09, 2004 10:12 am
by frankpmjr
I got a bunch of warnings but I can't seem to reply to this post with any content.
Posted: Sat Oct 09, 2004 10:16 am
by frankpmjr
I think they mean to check the php.ini file, how can I find that?
Posted: Sat Oct 09, 2004 10:16 am
by feyd
IE5 on a Mac? Upgrade to a newer browser.
I don't see any other reason you wouldn't be able to post with the output.. granted, you may need to break it apart if it's really huge.
Posted: Sat Oct 09, 2004 10:16 am
by frankpmjr
The errors are that the file failed to open, chmod not permitted and unable to move the uploaded file out of the temp directory.
Posted: Sat Oct 09, 2004 10:18 am
by feyd
which file failed to open?
Posted: Sat Oct 09, 2004 10:19 am
by frankpmjr
No, IE on a PC. When I try to post the errors (either by cut and paste or retyping I get:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator,
wwwadmin@devnetwork.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Posted: Sat Oct 09, 2004 10:20 am
by frankpmjr
The file that failed to open was:
move_uploaded_file(../downloads/0.txt): failed to open