homepage Welcome to WebmasterWorld Guest from 54.227.215.139
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP can't create files?
Scooter24

10+ Year Member



 
Msg#: 1162 posted 10:24 pm on Sep 10, 2002 (gmt 0)

My provider's server supports PHP 4, but I can't create a new file with a PHP script. Is it something my provider set or is there a way to create a file in PHP (such as with a "fcreate" function)?

 

Frank_Rizzo

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1162 posted 11:08 pm on Sep 10, 2002 (gmt 0)

have you checked that the directory you are writing too has the correct rights?

hpche

10+ Year Member



 
Msg#: 1162 posted 12:13 am on Sep 11, 2002 (gmt 0)

You can use fopen - [php.net...] - to create a file. You'll need to check the correct permissions on the script and directory are set though, or you'll end up with 'Permission Denied' errors.

Scooter24

10+ Year Member



 
Msg#: 1162 posted 1:55 am on Sep 11, 2002 (gmt 0)

What permissions do I need? Is 755 enough or do I need a 666? (if the directory is on my site)

ergophobe

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 1162 posted 9:37 pm on Sep 11, 2002 (gmt 0)


(if the directory is on my site)

I think the deal is that you need correct permissions for the PHP process, not for you, and the PHP process is not the owner of the directory. So you probably need at least group write permission (665 or 765) but probably 666 or 766. Try 665 first, then 666. If you have to grant public write to write the file, what I have done is surround the file write line with chmods and change the perms, write the file, then take away public write. Not the best, but it's better than nothing.

Tom

Scooter24

10+ Year Member



 
Msg#: 1162 posted 12:06 pm on Sep 12, 2002 (gmt 0)

Well, I tried that yesterday (surrounding the fwrite with chmods) and it didn't work. The PHP script wasn't allowed to chmod the file or the directory. I'll have to talk with my provider about this.

mrgym

10+ Year Member



 
Msg#: 1162 posted 2:39 pm on Sep 12, 2002 (gmt 0)

Here's the deal. The "user" trying to write the files is your webserver. If the webserver is run as "nobody" then "nobody" would need to have rights to write files whereever your script calls for them.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved