Re: FTP upload
| From: | Rosen | Date: | Wed, 23 Apr 2003 15:18:30 +0000 |
| Subject: | Re: FTP upload | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145027@lists.php.net to get a copy of this message | ||
Thanks, but I'll need to do this with ftp commands, because on this way I
must know the full path to my ftp directory, but
host company may change my default directory and this will not work :((
Can you tell me how can I do this with PHP FTP commands.
Thanks
Rosen
"Jason Wong" <php-general@gremlins.biz> wrote in message
news:200304211745.49199.php-general@gremlins.biz...
> 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.
> */
>