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.
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.
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.
24 Users Online
Copyright © 1996 - 2018. All Rights Reserved.