tags:

views:

71

answers:

2

Hello, I am creating a file with php. I just want to be able to create it, with no content, under a directory. Then I want to be able to edit it when I access my server with ftp. I can't! The user of php is different from the ftp user, and this last one does not have permissions to change it! I tried chmod,umask,chown, but nothing works. Anybody knows how to do it? Thanks

Cheers

A: 

give your file world writeable permissions chmod('filename', 0666)

knittl
I did that! This is the message that I get when by ftp I try to change the file:Upload of file was successful, but error ocurred while setting the permissions and/or timestamp. If the problem persists, turn on "Ignore permission errors" option
George
Ok maybe thats just an annoying thing of winscp! I will ignore it! Thanks
George
Dont set the value to 0777 as stated above.
Pino
+4  A: 

In PHP, after you move or otherwise create the file, just change it's permissions using chmod():

chmod($file, 0666);

Don't give execute permissions (which 0777 would) otherwise someone on the system can execute it. Huge security vulnerability.

cletus
How could someone do that? Can't I have a folder (let's say pictures) with those permissions set?
George
If the file is under the document root, imagine someone uploads somefile.php and then calls it through a Web browser. Not good. Or imagine if they upload somefile.pl and they have access to the system and can then run the script and it runs as the same user as the Webserver. Not good either.
cletus