FTP and Creating New Files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

FTP and Creating New Files

Post by Mr Tech »

Hey there,

I have written a PHP script that can create, edit and delete PHP files on the web server.

My script is used on my clients websites which use CPanel, so all of the files and folders are saved in the /public_html/ folder.

I currently use this code to create a file in the /public_html/ folder:

Code: Select all

<?php
$fp=fopen("filename.php",w);
fputs($fp,$content);
fclose($fp);
?>
Which works fine ONLY if the /public_html/ folder is CHMODed to 777.

However, their host have an automatic script that changes the CHMOD of the /public_html/ folder to 750 resulting in my script not being able to create files.

Is there a way to create new files without having the /public_html/ folder set to 777?

Cheers

Ben
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there's a potential to ftp it into the folder... just write the file to a writable location (like a temporary folder or something) then ftp it into place.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Thanks mate :)

Is it possible to move a file into an unwriteable folder without FTP at all?

Thanks

Ben
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can try it, but I'd say no.
Post Reply