Solved

move_uploaded_file and ownership/permissions

Posted on 2006-07-19
2
979 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 100 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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

732 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