icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Help with PHP and images

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 17th, 2005, 10:20 PM   #1 (permalink)
Registered User
Seasoned Poster
 
Stutterfly's Avatar
 
Joined in May 2004
Hosted on Saprus
57 posts
Gave thanks: 0
Thanked 0 times
Help with PHP and images

Ok, I am running a Random Image script, I know it works, because it works on the server where another site I work on is at, but, I keep getting errors on surpass.

<?

$font="Verdana";
$dir=$_SERVER['DOCUMENT_ROOT']."/fe_planet/media/sprites/9/body";//change to your dir
$types=array('jpg'=>'jpeg','jpeg'=>'jpeg','jpeg'=> 'jpeg','png'=>'png');
$dh=opendir($dir);
while($data=readdir($dh)){
if($data=='..' || $data=='.' || is_dir($dir.$data))
continue;
$temp_ext=explode('.',strrev($data),2);
$temp_ext=strrev($temp_ext[0]);
if($types[$temp_ext] || $_GET['debug'])
$sigs[]=$data;
}
mt_srand((double)microtime()*10000000);
$i=mt_rand(0,(count($sigs)-1));
$sig=$dir.$sigs[$i];
$ext=explode('.',strrev($sig),2);
$ext=strrev($ext[0]);
$type=$types[$ext];
if(!$type){
header('content-type: image/jpeg');
$im=imagecreate(500,100);
$white=imagecolorallocate($im,255,255,255);
$black=imagecolorallocate($im,0,0,0);
imagefill($im,0,0,$white);
imagettftext($im,13,0,0,10,$black,$dir.$font,'I\'m sorry but i can\'t display the image with the file type '.$ext);
imagejpeg($im,'',100);
imagedestroy($im);
}else{
header("Content-Type: image/{$type}");
readfile($sig);
}

?>

The image “http://exxdee.net/hostees/fe_planet/rand_char.php” cannot be displayed, because it contains errors.

That is the error I get.
Stutterfly is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 19th, 2005, 10:39 AM   #2 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
$sig=$dir.$sigs[$i]; should be changed to $sig=$dir .'/'. $sigs[$i];

The current existing script, since dir is written without the trailing slash, sig ends up becoming /path/to/filefilename instead of /path/to/file/filename
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On