Forum Moderators: coopster
copy($URL,$cachefile);
This worked very well on my old server, but it does not work on the new one.
I am getting the following error:
Unable to open 'http://[...]' for reading: No such file or directory in /local/copyfile.php on line 23
I searched for more than two hours, but I have not found the solution.
On the php.net I found the following:
Note: As of PHP 4.3.0, both source and dest may be URLs if the "fopen wrappers" have been enabled.
Thanks in advance,
--
globay
I think, the error might be in opening the file, that I want to copy:
Unable to OPEN [...]
Also it is very strange, that PHP thinks that the file is supposted to be in the same folder as folder as the php-file with the copy function. It should look for the file at the remote host [http://...]
--
globay
Now I am using this code, which for unknown reasons ends up in an infinite loop, once in a while.
$fi=fopen($URL,"r");
$fl=fopen($cachefile,"w");
while(!feof($fi)){
fwrite($fl,fread($fi,20000));
}
fclose($fl);
fclose($fi);
Does anybody have an idea why?
When reading from network streams or pipes, such as those returned when reading remote files or from popen() and proc_open(), reading will stop after a packet is available. This means that you should collect the data together in chunks...
Also, this thread regarding Help with fread() - Limit size of file being read? [webmasterworld.com] may offer some insight...