File Upload Error
Please support our PHP advertiser: Free Online Load Test - How many visitors can your web site handle?
![]() |
Hi!
I am using the following code for a file upload-
While it works fine on my localhost, when I upload it to the server, I get-
Temporary Location is: /tmp/phpw1v73L
Target Path is: /home/infotech/myhomepage/uploads/a.txt
Warning: move_uploaded_file(/home/infotech/myhomepage/uploads/a.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/infotech/myhomepage/upload.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpw1v73L' to '/home/infotech/myhomepage/uploads/a.txt' in /home/infotech/myhomepage/upload.php on line 15
There was an error uploading the file, please try again!
-----------
Is it due to permissions?
Because I am able to do mv /tmp/foo /home/infotech/myhomepage/uploads/
Any ideas?
Thanks
I am using the following code for a file upload-
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['b1'])) { if($_FILES['uploadedfile']['name'] !="") { $target_path = "/home/infotech/myhomepage/uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); echo("Temporary Location is: ".$_FILES['uploadedfile']['tmp_name']."<br />"); echo("Target Path is: ".$target_path."<br />"); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } else { die("No file specified"); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>File Upload</title> </head> <body> <form enctype="multipart/form-data" action="<?php echo($_SERVER['PHP_SELF']);?>" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" name="b1" value="Upload File" /> </form> </form> </body> </html>
While it works fine on my localhost, when I upload it to the server, I get-
Temporary Location is: /tmp/phpw1v73L
Target Path is: /home/infotech/myhomepage/uploads/a.txt
Warning: move_uploaded_file(/home/infotech/myhomepage/uploads/a.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/infotech/myhomepage/upload.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpw1v73L' to '/home/infotech/myhomepage/uploads/a.txt' in /home/infotech/myhomepage/upload.php on line 15
There was an error uploading the file, please try again!
-----------
Is it due to permissions?
Because I am able to do mv /tmp/foo /home/infotech/myhomepage/uploads/
Any ideas?
Thanks
My blog on .NET- http://dotnet.tekyt.info
I think this may be to do with permissions on the folder. Your permissions are not the same as php's permissions. The fix depends on what server you are using, but in a Linux server you can use a chmod command on the directory to change the permissions. You need write access for the Other group of permissions (the second-last bit). Use the command
chmod 766
to assign full access to the directory's owner, read/write access to the owner's group and read/write access to other users (which includes php/www).
I'm not sure about a windows server sorry, maybe someone else can help if you are using a windows server.
chmod 766
to assign full access to the directory's owner, read/write access to the owner's group and read/write access to other users (which includes php/www).
I'm not sure about a windows server sorry, maybe someone else can help if you are using a windows server.
There are no stupid questions, only those too stupid to ask for help.
![]() |
Similar Threads
Other Threads in the PHP Forum
- File upload help (PHP)
- File Upload Help (PHP)
- file upload code.....need attention (PHP)
- Spybot "Error during check!" (Viruses, Spyware and other Nasties)
- MS Visual++ 6.0 - Error C2146, C2501 ... (C++)
- Bridge.dll error (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: i need urgent help Parse error
- Next Thread: User based look & feel customization of site
•
•
•
•
Views: 843 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode