Page 1 of 1
creating a file on a remote server
Posted: Mon Oct 02, 2006 4:31 pm
by psavvy
hi,
What is the best way to create a file on a remote server in php. Would fsocketsopen() be a way?
And if possible the files should be created with a username and password.. the same one i use login in with like a ftp client.
But this needs to be done with php. Any help would be much appreciated.
Posted: Mon Oct 02, 2006 4:35 pm
by chocolatetoothpaste
Just use
Code: Select all
$handle = fopen($filename, 'a');
fwrite($handle, $content);
It will try to write to a file, or create it if it doens't exist.
I don't know if you can give the file a username/password, but you could create a sub-folder for each user that is named after their user ID or some other identifier.
Posted: Mon Oct 02, 2006 4:41 pm
by Mordred
If by "remote server" you mean a third party (the client and server being the natural two), you can try the ftp_* functions.
Posted: Mon Oct 02, 2006 4:41 pm
by Luke
you need some sort of permission to create files on a remote server... do you have ftp access to this remote server?
Posted: Mon Oct 02, 2006 4:51 pm
by psavvy
yes i have full access.
what i need to do is get content from a database, create an html page, and send it to another website/server whatever. the files need to be created there.
i'm just not sure what the best way is. if i use the ftp function that php provides, i'd first have to create a local file no?