Cynosure.X International LLC

:

Add Comment | Related Links | TrackBack
Related Content

PHP Upload Doesn't Follow umask Specification

Today, I encountered a problem. I needed Apache and PHP to store files with the permission mask of 664 (rw-rw-r--). So I set the umask to 002 for Apache. Everything worked fine until I tried to upload a file using web server POST. The file stored on the hard disk has a permission of 600 (rw-------). No amount of umask tinkering would solve the problem. Nothing on the web was any help either. Many people had the same problems, but no body has answers.

After a few hours of tinkering and trying new things, I finally figured out a work around. The PHP upload handler uses the $_FILES variable with an efficient "move_uploaded_file" function call. I replaced the "move_uploaded_file" function call with the "copy" function call. Now it works wonderfully, the resulting file has the right permission. The temporary file, with the wrong permission, is automatically deleted by PHP. I'm a happy camper.

Chieh Cheng
Mon, 25 Jun 2007 23:01:28 -0700

Super!
So easy!
Your my hero!

T�z
Wed, 29 Oct 2008 14:41:51 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 7 + 1?
Click button only once, please!

TrackBack

TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

156 Users Online

Hacking Digital Cameras
Fun for Photographers


Get Our

Memecoins!



Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.