?
Solved

move_uploaded_file and ownership/permissions

Posted on 2006-07-19
2
Medium Priority
?
981 Views
Last Modified: 2011-10-03
Hello.

The following comment was posted by jest3r: (http://ca.php.net/manual/en/function.move-uploaded-file.php#57959)

                  "It seems that move_uploaded_file use the GROUP permissions of the parent directory of the tmp
                  file location, whereas a simple "copy" uses the group of the apache process. This could create a
                  security nighmare if your tmp file location is owned by root:wheel"

I have run into this problem.  How can I get around it?  Is there another command, or a custom function that would do the trick?

 
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Assisted Solution

by:ThG
ThG earned 400 total points
ID: 17137827

no, that's not possible unless your system has screwed up permissions (like setgid /tmp directory?).

how can you assert that you have run into this problem?

you can get more information about what's going on this way:

var_dump(stat($_FILES['....']['tmp_name']));
0
 
LVL 9

Accepted Solution

by:
cristi_2112 earned 1600 total points
ID: 17138250
The best solution is to make a habit of running a chmod command after each upload with the desired rights.
So after each:
move_uploaded_file($file['tmp_name'], $destination.'/'.$file['name']);

call:
chmod($destination . '/' . $file['name'], $permissions);
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question