Jump to content

Recommended Posts

I'm on a Suse Linux box running Apache and using PHP to upload a file to the server.  I use this same script on our test server and it works fine, but on the production we have our websites stored on a SAN so the files aren't directly stored on the server.

 

But the problem seems to be happening at this line of code

 

move_uploaded_file($tempPath, $filepath) or die("Error while moving temporary file to target path: " . $relativePath);

 

Its when the uploaded file is moved from the temp location to the official location.

 

My real question here is, I have to use "sudo" before any commands to the file locations on the SAN.  Do you think I would need to use SUDO somewhere in the script?  If so, where??

Link to comment
https://forums.phpfreaks.com/topic/193993-having-problem-moving-uploaded-file/
Share on other sites

No. You shouldn't be sudo'ing in a script. This may be an suexec issue or your uid may not have the appropriate permissions to write to the network store on the SAN.

 

777 may work, but it's kinda crazy, although many people do it just so they don't have to deal with worrying about it.

 

check some of the files on the SAN repositories with

 

$ ls -la

 

to determine what permissions are typically placed on the files, as well as who owns them. In the general sense, it should be the user that Apache runs under that has the problem of meeting the security requirements to access the network store.

 

There are often kludges that you can use in a heterogeneous environment if you're having problems with things like ACLs, such as what people are having lots of problems with on Mac systems.

 

For example, the chmod for the new Macs includes a '-N' option - a kludge to disable ACLs which have been causing problems.

 

wrt 777, well, you can't do that on my servers, as many people have found out. All of my servers are configured to provide an error for having such a complete disregard for security.

 

Again, separate yourself from the the user performing the action in your scripts - it isn't you. Check to see who httpd is running as, and I suspect that's where your problem is.

  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.