Re: FTP upload
| From: | Jason Wong | Date: | Mon, 21 Apr 2003 09:45:49 +0000 |
| Subject: | Re: FTP upload | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144614@lists.php.net to get a copy of this message | ||
On Monday 21 April 2003 03:20, Rosen wrote:
> > > I have no rights to write on my WEB server, but I have FTP access to
> > > another server with rights to write there.
> > > Rosen
> >
> > You can read a file to memory, alter it and write to ftp without having
> > to save it first.
> Can you give me a sample how to do this ?
$ftp = 'some.ftp.server';
$user = 'some-username';
$pass = 'some-password';
$file = '/some/path/to/a/file';
$somecontent = "What did you think this was?\n";
if (!$fp = fopen ("ftp://{$user}:{$pass}@{$ftp}{$file}",
"w")) {
die("Cannot open the file for writing");
}
if (!fwrite($fp, $somecontent)) {
die("Cannot write to file!");
}
print "Success, wrote ($somecontent) to file";
fclose($fp);
I'll let you figure out how to read in a file. Hint file().
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Avert misunderstanding by calm, poise, and balance.
*/