jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 [quote author=Yesideez link=topic=245968.msg1149792#msg1149792 date=1238678182] Just after [b]$found=type[/b] add this line: [code=php:0]echo 'FOUND:'.$type; ok,only from the stuff i know (not a lot) you put it after the end ({) eg. [code<?php session_start(); error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL ^ E_NOTICE); $picname = $_GET['picname']; $arrFileTypes = array("gif", "jpg", "jpeg", "png"); foreach ($arrFileTypes as $type) { if ($fh=@fopen('images/'.$picname.'.'.$type,"r")) { $found=$type; fclose($fh); } } echo 'FOUND:'.$type; ?>[/code] and it prints FOUND:png i use this url http://jamesco.com/PhotoProcess.php?memberid=not and its correct it is a PNG P.S jamesco.com is a virtual domain for my localhost lol Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799454 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 ok i put this url in http://jamesco.com/PhotoProcess.php?memberid=apply and it still prints the same. . . . . one problem the image i was trying to view is a GIF :S but its printing FOUND:png Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799457 Share on other sites More sharing options...
Yesideez Posted April 2, 2009 Share Posted April 2, 2009 Check out the imagecreatefrom???() in GD library... http://uk.php.net/manual/en/ref.image.php Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799459 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 ok its a problem with the array as u can see iv changed it and im getting the same, if i remove the PNG from the array it displays JPEG basically its displaying the end word of the array :S Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799461 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 i dont have GD library compatability , does anyone know what is wrong with that array ? Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799462 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 check this out im really confused :S ok i changed the code to this <?php error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL ^ E_NOTICE); $picname = $_GET['picname']; $FileTypes = array("gif", "jpg", "jpeg", "png"); foreach ($FileTypes as $type) { if ($fh=@fopen('images/'.$picname.'.'.$type,"r")) { $found = $type; fclose($fh); } } echo 'FOUND: '. $type; echo '<br>'; echo 'FOUND: '. $picname; echo '<br>'; echo 'FOUND: '. $found; ?> the url is this http://jamesco.com/PhotoProcess.php?picname=apply the real image is called * apply.gif * look at what has been printed FOUND: png FOUND: apply FOUND: gif the $found var is working but i still dont know what to do to display :S Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799469 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 <?php error_reporting(E_ALL | E_NOTICE); error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL ^ E_NOTICE); $picname = $_GET['picname']; $root = "images/"; $FileTypes = array("gif", "jpg", "jpeg", "png"); foreach ($FileTypes as $type) { if ($fh=@fopen('images/'.$picname.'.'.$type,"r")) { $found = $type; fclose($fh); } } echo 'FOUND: '. $type; echo '<br>'; echo 'FOUND: '. $picname; echo '<br>'; echo 'FOUND: '. $found; echo '<br>'; echo "<img src='$root$picname.$found'>"; ?> this prints FOUND: png FOUND: apply FOUND: gif THE IMAGE IS HERE!! and is all working but i still dont know how to use externally :S Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799473 Share on other sites More sharing options...
premiso Posted April 2, 2009 Share Posted April 2, 2009 What exactly are you trying to do? Get an image to display when you goto your URL? <?php $picname = $_GET['picname']; $root = "images/"; $image = glob($root . $picname . ".*"); if (!is_array($image) || count($image) < 1) { $image[0] = "no-image.gif"; // make sure you have this file incase there is no image found. } $image = $image[0]; $type = end(explode(".", $image)); $size = filesize($image); ob_start(); header('Last-Modified: '.date('r')); header('Accept-Ranges: bytes'); header('Content-Length: '.$size); header('Content-Type: image/' . $type); readfile($image); ob_end_flush(); ?> The code is untested, but that is what I gather you are after. Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799492 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 no i need it to display the image that is at the end of the * picname * in the url and auto find and add the prefix. Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799499 Share on other sites More sharing options...
premiso Posted April 2, 2009 Share Posted April 2, 2009 no i need it to display the image that is at the end of the * picname * in the url and auto find and add the prefix. I doubt you understand what I just did, or eve tried it. Anyhow your answer is simple. <?php $picname = $_GET['picname']; $root = "images/"; $image = glob($root . $picname . ".*"); if (!is_array($image) || count($image) < 1) { $image[0] = "no-image.gif"; // make sure you have this file incase there is no image found. } header("Location: images/" . $image); ?> Will redirect you, thus changing the url etc. That would be the only way to do what you have just described in the above. You cannot change the url without doing a redirect or formal submital. As far as will this work if you just include that URL in an image tag, I have no clue. I think it would, but yea. The only way to find out is for you to test it. Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799501 Share on other sites More sharing options...
jamesxg1 Posted April 2, 2009 Author Share Posted April 2, 2009 no i need it to display the image that is at the end of the * picname * in the url and auto find and add the prefix. I doubt you understand what I just did, or eve tried it. Anyhow your answer is simple. <?php $picname = $_GET['picname']; $root = "images/"; $image = glob($root . $picname . ".*"); if (!is_array($image) || count($image) < 1) { $image[0] = "no-image.gif"; // make sure you have this file incase there is no image found. } header("Location: images/" . $image); ?> Will redirect you, thus changing the url etc. That would be the only way to do what you have just described in the above. You cannot change the url without doing a redirect or formal submital. As far as will this work if you just include that URL in an image tag, I have no clue. I think it would, but yea. The only way to find out is for you to test it. Hiya, i tested the top code you posted and it worked!! thankyou so much mate !! seriusly your a life saver !! and thankyou so much to everyone else who tried !! Quote Link to comment https://forums.phpfreaks.com/topic/152206-solved-how-do-i-make-it-ignore-a-prefix/page/2/#findComment-799507 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.