Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting file from ftp site

Status
Not open for further replies.

pr0fess0r

Programmer
Jul 10, 2001
25
NZ
Hi

Whats the best approach to overwriting a file from an ftp site with PHP?
I know you cant overwrite a file with fopen, but I dont want to use ftp functions to log in and delete the file because I am using fopen to stream data from a variable into a file, i.e. I'm opening the connection with:
if(!$handle = fopen ($ftphoststring, "wt")){
print "Could not open FTP Site ".$ftphoststring;
exit;
}

and writing with

if (!fwrite($handle, $data)) {
print "Cannot write to file!";
exit;
}

So I guess I need to know
a. How to stream data from a variable to a file on an ftp site using the ftp functions like ftp_nb_put without having to make a local temp file, and handle overwriting/deleting;
or
b. How top query for and delete a file on an ftp site using fopen so I can write a new version

cheers
 
Hi!

You are using fopen with the ftp wrappers.

However, there is a set of FTP functions that you can use to issue specific commands, including the delete command:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top