Jump to content

phpthumb won't display image


quasiman

Recommended Posts

Hello all!

I'm reading an xml file to display products (which works fine), but the images are too big and I want to resize them using phpthumb.  For a few reasons, I don't want to use full URLs to the image so I've got curl downloading the file.  The file is downloaded fine as well.

 

The only problem I'm having is getting phpthumb to open the file.  No error messages at all.

This is through XAMPP for Windows

PHP Version 5.3.1

GD Enabled

cURL Enabled

 

Here's my code...I'm sure this is simple, and any help would be greatly appreciated!

<?php
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log');
error_reporting(E_ALL);
//removing old files first, so they download/display in correct sequence
$file_type = array('gif','jpg','png');
foreach($file_type as $ext){
   foreach(glob('cache/*.'.$ext) as $image){
$filetime = filemtime($image);
$timenow = time();
$twodays = 3600*48; // two days ago
	if (($timenow - $filetime) >= $twodays) {
		//echo "$image size " . filesize($image) . "\n<br />";
			@unlink($image);  
	}
   }
}

$url = "productsearch.xml";
$xml = simplexml_load_file('productsearch.xml');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>XML Reading Page</title>
<style type="text/css">
*{margin:0;padding:0}
p{margin:0 0 .5em 0}
h1{margin:1em 0;text-align:center}
img {border:0px;}
#catlist{
border:1px dashed #ccc;
border-bottom:none;
width:660px;
margin:10px auto;
}
#catlist dl{
width:640px;
margin:0 auto;
border-bottom:1px dashed #ccc;
padding:10px;
overflow:hidden;
background:#f2f2f2;
}
#catlist dd{overflow:auto}
#catlist dt strong{
float:right;
padding:0 0 0 20px;
}
#catlist dt img{
float:left;
margin:0 10px 0 0;
border:1px solid #000;
}
* html dd{height:1%}/* 3px jog*/
</style>
</head>
<body>
<h1>XML Results</h1>
<div id="catlist">
<?php
foreach ($xml->item as $link)  {
$filepath = $link->imageurl;
$filename = basename($filepath);
$filecache = "cache/" . basename($filepath);
$ch = curl_init($filepath);//Here is the file we are downloading
$fp = fopen($filecache,'w');
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
<dl>
	<dt><a href="<?php echo $link->linkurl; ?>"><img src="phpThumb.php?src=<?php echo $filecache."&w=93"; ?>" /></a><a href="<?php echo $link->linkurl; ?>"><?php echo $link->productname; ?></a></dt>

	<dd>
		<p><?php echo $link->description->short; ?></p>
	</dd>
	<dd>
		<p><?php echo $link->description->long; ?></p>
	</dd>
</dl>
<?php } ?>
</div>
</body>
</html>

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.