Getting files from server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hoyo
Forum Newbie
Posts: 2
Joined: Thu Jan 09, 2003 11:30 am

Getting files from server

Post 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:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
hoyo
Forum Newbie
Posts: 2
Joined: Thu Jan 09, 2003 11:30 am

Post by hoyo »

With this code I get "Bad file descriptor".[/quote]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply