Web Hosting Talk







View Full Version : how to ftp upload a file from a string using php?


vSector
08-26-2002, 03:53 AM
Hi,

I am building a file manager that works on one server(main server) and browsers another(file server) using php and the FTP functions. I am now trying make a section for creating passworded directories.

I need to create an .htaccess and .htpasswd on the file server without creating a the files on the main server. how would i accomplish this?

it would be perfect if there was a ftp_create_file but i dont think there is :-( any suggestions are welcome

Mark-TFL
08-26-2002, 06:49 AM
I think your best bet would be to create the two files on the main server, copy them accross to the FTP server and then delete them from the main server. I don't think there's another way of doing it other than that.

vSector
08-26-2002, 07:54 AM
yeah thats what i thought...

thanks

apokalyptik
08-26-2002, 03:46 PM
(oops did i just disconnect modem users ;)

anyhow...


i dont have time right now to see if this work, but fopen should be able to open a URL... have you tried


$fp=fopen('ftp://'.$username.':'.$password.'@'.$hostname.':'.$portnumber.'/path/to/file', 'w');
fputs($fp, 'whatever?');
fclose($fp);


??? just an offhand thought...

(p.s. make sure you have appropriate write access via ftp before testing this...)