danjapro Posted April 4, 2012 Share Posted April 4, 2012 Here is my code, below. It is gathering the $url with the corret images. But poduces and error on line 50. Failed to open stream. No such file or directory. By this line: readfile($file_name); What Am I missing, beyond strong programmer mind set. $merch_map = "http://spot_map"; $dir = "/opt/digistrive/tmp/media/current"; class merch_imgs { public function __construct() { $this->merch_imgs1(); } public function __call($method, $_) { $count = str_replace('merch_imgs', '', $method); echo "$count "; $this->{"merch_imgs" . ++$count}(); } } class thousand_printer extends merch_imgs { public function merch_imgs1000() {} } //03-2012. Location of merchant, if no image use place holder $thumbnails = implode(',', range(1, 10000)); $ext = ".png"; for($thumbnails = 0; $thumbnails < 10000; $thumbnails++) { $url = $merch_map.'/'.$thumbnails.''.$ext; echo $url . '<br>'; //echo '<img src='.$url.' border=0/>'; downloader($url, $dir); } function downloader($url){ $file_name = basename($url); $generated_files = geturl($url, $url); //file_put_contents($file_name); file_put_contents($url, $url = var_export($file_name,true)); $size=strlen($generated_files); if($size==0){exit(0);("<b>Error:</b>not found!");} //header('Content-type: application/force-download'); //header('Content-Disposition: attachment; filename=' . $file_name); //header('Content-Transfer-Encoding: binary'); //header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); //header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); //header('Pragma: public'); //header('Content-Length: ' . $size); readfile($file_name); unlink($file_name); } function geturl($url, $referer) { $headers[] = 'Accept: image/png'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $user_agent = 'ONLY_MY_HOST'; //$useragent = $url; $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $headers); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_USERAGENT, $user_agent); curl_setopt($process, CURLOPT_REFERER, $referer); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($process); curl_close($process); return $return; } //downloader($dir, $url); //Merchant Images if($url && $user_agent){ file_get_contents($url); die(); } Link to comment https://forums.phpfreaks.com/topic/260352-need-help-with-http-failed-to-open-stream/ Share on other sites More sharing options...
BMR777 Posted April 4, 2012 Share Posted April 4, 2012 Are you trying to load a valid web address? You have: $merch_map = "http://spot_map"; Then you have: $url = $merch_map.'/'.$thumbnails.''.$ext; Which gets passed to your download function and then to readfile. I think maybe it's having trouble because you're not ending up with a valid URL, that is http://spot_map/opt/... is not a valid url, there's no domain extension. Link to comment https://forums.phpfreaks.com/topic/260352-need-help-with-http-failed-to-open-stream/#findComment-1334429 Share on other sites More sharing options...
danjapro Posted April 4, 2012 Author Share Posted April 4, 2012 If you notice $merch_map is just the url it calls $url is $merch_map + thumbnail image(1-1000). + $ext (.png) Completed $url it is calling is $url ="http://xxxxx.com/images/spot_map/404.png" I have, the issue is on this line readfile($file_name); Here is error: PHP Warning: readfile(460.png): failed to open stream: No such file or directory in /opt/lib/dg/email/merch_map_imgs.php on line 50 Link to comment https://forums.phpfreaks.com/topic/260352-need-help-with-http-failed-to-open-stream/#findComment-1334465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.