File Upload Permissions

I am trying to set up a simple php page to allow people to upload files to the server. I keep getting this:

Warning: move uploadedfile(/file.ext): failed to open stream: Permission denied in /Library/WebServer/upoad.php on line XX

What permissions need to be set? I tried a few different options and can't seem to get it to work.



G5 Xserve Mac OS X (10.4.6)

Posted on May 17, 2006 5:51 AM

Reply
10 replies

May 17, 2006 8:14 AM in response to Eric Nelson1

The user as whom the web server is running needs to have permission to move the file where you are putting it. If you're trying to put it at the root of your startup disk ("/file.ext"), you'd need to open the permissions up on "/" -- but that wouldn't be a good idea.

Make sure you're writing the file to a safe directory -- create a directory just for this and give it only the necessary permissions.

May 17, 2006 8:50 AM in response to Wesley Furgiuele

I tried both the move uploaded files and the copy with no success.
Heres what I have
Form = multipart/Form data etc
The file browser name is "fileProject"
The upload folder is in the same level as the script

PHP CODE
// get and upload file
if (isset($_FILES['fileProject']['name']))
{
$reqFile = $_FILES['fileProject']['name'];
$uploadFolder = 'requestFiles';
copy($ FILES['fileProject']['tmpname'],$uplaodFolder . "/" . $_FILES['fileProject']['name'])
or die("There was an error uploading your file. This request has not been submitted.");

}
/PHP CODE

May 17, 2006 9:26 AM in response to Eric Nelson1

Do you happen to have a particular value for upload tmpdir in your php.ini file? Typically I think it's either left blank or given the value "/tmp". This is where the file winds up when the script uploads it to the system, before you call the "move uploadedfile()" function. Perhaps if you don't have permissions to write to this directory, that's where the error is occurring?

I'm not sure it will help, but how about giving your uploadFolder the full filesystem path as well (/Library/WebServer/Documents/requestFiles, customized for your document root)?

And I would stick with the move uploadedfile() file function over the copy function.

May 17, 2006 9:38 AM in response to Eric Nelson1

Do you happen to have a particular value for upload tmpdir in your php.ini file? Typically I think it's either left blank or given the value "/tmp". This is where the file winds up when the script uploads it to the system, before you call the "move uploadedfile()" function. Perhaps if you don't have permissions to write to this directory, that's where the error is occurring?

I'm not sure it will help, but how about giving your uploadFolder the full filesystem path as well (/Library/WebServer/Documents/requestFiles, customized for your document root)?

And I would stick with the move uploadedfile() file function over the copy function.

Jun 8, 2006 4:33 AM in response to Infinite Loop, 1

Yes, I created a new folder, gave it the proper permissions (which are basically anyone can write to it) I then opened php.ini and pointed all temp files to use that folder.
I still think this should not be necessary. But I can't say that with the setting up of permissions for the network I didn't lock the original temp folder down accidently somewhere.

Good luck!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

File Upload Permissions

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.