mattcairns Posted December 15, 2006 Share Posted December 15, 2006 I am storing uploaded images in a non-web accessible folder(for security reasons), and need to display them in an HTML table. I've been working on this all week, and haven't been able to find a solution that did not involve using headers. I can't use headers, as far as I know, due to these images being in the body of the document. Any ideas? Link to comment https://forums.phpfreaks.com/topic/30795-solved-help-displaying-images/ Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 You can store the images directly into your MySQL database, although it may be difficult to backup because of the huge binary data that will be in there. However, it is the most secure way, other than using headers, to display your images and not have them accessible through the web.Here is a good tutorial:http://www.phpfreaks.com/tutorials/85/0.phpHop ethat helps! Link to comment https://forums.phpfreaks.com/topic/30795-solved-help-displaying-images/#findComment-141966 Share on other sites More sharing options...
mattcairns Posted December 15, 2006 Author Share Posted December 15, 2006 thanks for the suggestion, but while waiting i found the solution i was looking for. here it is for anyone who may need it.code to display image on page:[code]<img src='disp_images.php?dir=IMAGE_DIRECTORY&img=IMAGE_NAME'>[/code]code to display image (disp_images.php):[code]<?##GET URL VARIABLES$dir = $_GET['dir'];$img = $_GET['img'];##CREATE FILE PATH$file_path = "/PATH/$dir/$img";chmod("$file_path", octdec(0777));$handle = fopen($file_path, "rb");$contents = fread($handle, filesize($file_path));fclose($handle);chmod("$file_path", octdec(0755));$img_type = mime_content_type($img);header('Content-type: $img_type');print "$contents";?>[/code]Hope this helps. Link to comment https://forums.phpfreaks.com/topic/30795-solved-help-displaying-images/#findComment-142040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.