Re: Show image img src=img.php?img=1.jpg help




RainCT wrote:
Can you copy all the code?

Sure, here it is:

<?php
session_start();
$dir = session_id();

if ($_REQUEST['img'])
{
$showfile = "./temp/$dir/".$_REQUEST['img'];

if (file_exists($showfile))
{
header("content-type: image/jpeg");
header('Content-Length: ' . filesize($showfile));
header("Content-Disposition: inline; filename=$showfile");
readfile($showfile);
}
}
echo "<img src='?img=1.jpg'>";
?>

If i keep session_start() "Save picture as" detects image as
untitled.bmp, if i delete
session_start() - everythng is fine, it is detected as jpeg, but i need
session_id(), so i have to start session...
And, i read somewhere in this group that i should add ini_set, like
this:

<?php
ini_set('session.use_cookies', '0');
ini_set('session.cache_limiter', '');
ini_set('session.cache_expires', '');
session_start();
$dir = session_id();
.....

When i do that the image type is detected correctly as jpeg, but the
file name is not, its named as the script, showimg.jpg,
filename=$showfile" is not working for some reason. But i guess its
good enough, it would be nice to detect the file name as well though

.



Relevant Pages

  • Re: Show image img src=img.php?img=1.jpg help
    ... When i do that the image type is detected correctly as jpeg, ... Just changing the name or header is not going to change the real file type. ...
    (comp.lang.php)
  • Validate an image type using php
    ... Does anyone know how to validate a particular image type using PHP? ... If I have a file and I want to ensure that it is a jpeg, ...
    (comp.lang.php)
  • Re: Show image img src=img.php?img=1.jpg help
    ... When i do that the image type is detected correctly as jpeg, ... But earlier you said this really is a bmp, ... I haven't actually tried mixing session_startwith header(); ...
    (comp.lang.php)
  • Re: Show image img src=img.php?img=1.jpg help
    ... When i do that the image type is detected correctly as jpeg, ... Just changing the name or header is not going to change the real file type. ... However, what should work is to use an img tag in this file, pointing at a file containing your PHP code. ...
    (comp.lang.php)
  • Re: JPG Not supported on my server, but GDlib enabled?
    ... then you should compile your GD with jpeg enabled option and then compile ... you can compile Apache and PHP. ... I have root access and have some php/mysql/apache installation experience ...
    (php.general)