|
Hi all, my name is Michele and
I want to download a file from an internet server and save the file in my server.
I use this code (this code run on a hosting X without errors)
<?php
//Dir src
$src_rep_win="http://www.threebestdogs.com/wp-content/gallery/aidi/";
//File
$file_win="aidi03.jpg";
//Dir dest
$dest_rep_win="";
//time to limit
$ttl=500;
function save_nightly_build($src_rep,$dest_rep,$file) {
//copy remote file
set_time_limit($ttl);
//Check if file exists
if(!file_exists($dest_rep.$file)){
//open src file
$srcfile = fopen($src_rep.$file, "r");
//open local file
$flocal = fopen($dest_rep.$file,"w");
//write local file
while ($contents = fread( $srcfile, 8192)) {
fwrite( $flocal, $contents, strlen($contents) );
}
//close the two files
fclose($srcfile);
fclose($flocal);
}
}
save_nightly_build($src_rep_win,$dest_rep_win,$fil e_win);
?>
But in my actual hosting I receive this errors:
Gateway Time-out
The gateway did not receive a timely response from the upstream server or application.
and in log:
Timeout waiting for output from CGI script /web/htdocs/www.. script address.
The script "works" and I really have a copy on my server but I have also these errors.
Someone could help me in debugging?
Thank you in advance,
Michele Alletto
PS the src server works very well!!
|