Jump to content

localhost php strangeness


frost

Recommended Posts

I have this issue seeing php manipulated images locally. Below is a file called random.php

 

I call on it like so - <img src="images/random/random.php?pic=random">

 

This works peachy online but it just shows a broken image locally.

 

<?php 

//read folder
$folder=opendir("."); 
while ($file = readdir($folder)) 
$names[count($names)] = $file; 
closedir($folder);

//sort file names in array
sort($names);

//remove any non-images from array
$tempvar=0;
for ($i=0;$names[$i];$i++){
$ext=strtolower(substr($names[$i],-4));
if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;}
}

//random
srand ((double) microtime() * 10000000);
$rand_keys = array_rand ($names1, 2);
//random image from array
$slika=$names1[$rand_keys[0]];

//image dimensions
$dimensions = GetImageSize($slika); 
if (isset($pic)){header ("Location: $slika");}
else {echo "<img src=\"$slika\" $dimensions[3]>";}
?>

 

Things I have thought of:

- images in the correct directory for the file to read, check.

- GD library? check -  from phpinfo > "GD Support  enabled"

 

Is there something else I can look at? Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/63984-localhost-php-strangeness/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.