I'm trying to call a jpg image that is in a directory above my html dir. How can I get that jpg file and use it in an img tag?
Jimmy
I'm trying to call a jpg image that is in a directory above my html dir. How can I get that jpg file and use it in an img tag?
Jimmy
Wish I had an answer for you, but I tossed the thread to Develish who may have a clue how to structure the tag you need.
I know on Windows, that if I am calling a file above my root - I need to use an absolute URL, like d:\domains\coreybryant.org\wwwroot\default.asp and the image would be in the folder d:\domains\coreybryant.org\secureimages\filename.j pg
Also the IUSR needs to have access as well (I think). I don't know if that us a start until someone comes in with PHP knowledge. Sorry I mainly do ASP and rely on the programmers for most of that
I'd use a script reading out the image and displaying it - I try to dig one out
Dunno if it may be done otherwise - chilihost is more webserver savy than I - i try to write my own tools
:-D
Thanks for the replies. I was able to use a script to pull and display the image.
Jimmy
oh darn
I was to slow - gimme a gun to my head - but for the others:
heres a way to do it
PHP Code:
<?php
$imgpath = '/path/to/images/'; //webserver user needs read access to this folder
if ($imgname != "")
{
$im = @imagecreatefromjpeg($imgpath.$imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
// if the call of the image failed create a nice little image with the error message
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
imagejpeg($im);
}
?>
Untested but it should do the work
:-D
Just in case - I totally forgot about Calling files outside of the public_html on server as well. The other solution might be a solution as well but not knowing PHP I thought that thread could help
Why not just use html? Im obviously missing something? like <img src="../image.gif"> or use the full web address?
Bookmarks