Jump to content
Sign in to follow this  
Cloud9247

.php Extension Image src Failure

Recommended Posts

Hello! I hope someone can help me with an issue I'm having.

 

 

Recently, I have had an issue displaying my banner on my website, which is has a .php file source. I have had any known changes to my php version (currently on 5.6, and considering to switch to 7.0); also, I am hosted through Dreamhost. If someone could look at the following code and offer any advice, I'd be greatly appreciative!

 

My link on the design:

<img src= "http://hayalkarga.com/theme/10/images/banner/banner.php" alt= "" />

The Image Code:

<?php
$dir	=	'';	
$file 	=	'';	
$num	=	0;		
$count	=	0;		
$array	=	array();


$allowedExtensions = array('jpeg', 'jpe', 'jpg', 'gif', 'png', 'bmp');


mt_srand((double)microtime()*1000000);
$dir = opendir('.');

while (false !== ($file = readdir($dir))) {
    if(!is_dir($file) && in_array(strtolower(substr(strrchr($file,'.'), 1)), $allowedExtensions)){
        $array[] = $file;
    }
}

$count = count($array);
$num = mt_rand(0, $count-1);

if($count > 0) {
    $size    = getimagesize($array[$num]);
    $stream = fopen($array[$num], 'rb');
    if(is_array($size) && $stream !== false){
        header('Content-type: '.$size['mime']);
        fpassthru($stream);
        exit();
    }
} else {
    echo 'Error: No Images';
}


?> 

I should note that the image works in my browser at http://www.hayalkarga.com/theme/10/images/banner/banner.php, but does not incorporate into the design when utilizing the link in HTML.

 

 

Thank you in advance!

Share this post


Link to post
Share on other sites

Please disregard this post... I just realized this output is related to an AVG update I have on my browser... Unable to delete this post though.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

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