Jump to content

Need help with HTTP failed to open stream


danjapro

Recommended Posts

 

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.