Page 1 of 1

Getting files from server

Posted: Thu Jan 09, 2003 11:30 am
by hoyo
I'm having some problems getting files from the server - I seem to be having some fairly common problems but haven't found any real fixes on the forums.

I've got some files on the server that I want to download. I've tried with copy() and FTP but both fail - are they related?

copy($remote_file, $local_file) ----- "Invalid argument"

or using ftp

ftp_conenct($server,21) ------- "Unable to find ftpbuf 0"

I'm going mad and would really appreciate the help! :evil:

Posted: Thu Jan 09, 2003 11:59 am
by volka
[url=http://www.php.net/manual/en/function.copy.php]http://www.php.net/manual/en/function.c ... quote]Note: As of PHP 4.3.0, both source and dest may be URLs if the "fopen wrappers" have been enabled. See fopen() for more details. If dest is an URL, the copy operation may fail if the wrapper does not support overwriting of existing files.[/quote]

try

Code: Select all

$fdR = fopen($remote_file, 'rb') or die('file not found: '. $remote_file);
$fdL = fopen($local_file, 'wb') or die('cannot open '.$local_file);
while(!feof($fdR))
{
   $part = fread($fdR, 4096);
   fputs($fdL, $part);
}
but take a look at http://www.php.net/manual/en/ref.filesy ... -url-fopen and http://www.php.net/manual/en/features.remote-files.php

Posted: Thu Jan 09, 2003 12:20 pm
by hoyo
With this code I get "Bad file descriptor".[/quote]

Posted: Thu Jan 09, 2003 12:38 pm
by volka

Code: Select all

<?php phpinfo(); ?>
will tell you wether url-wrappers are enabled or not.

Code: Select all

PHP Core
Directive                Local Value Master Value
allow_url_fopen                1             1
if you don't have this in the output no url-wrappers are available.