Jump to content

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

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.