| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Registered User
Seasoned Poster
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. |
|
|
|
|
|
#2 (permalink) |
|
All Ur Base R Belong 2 Us
Excelling Contributor
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 |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|