delickate Posted September 22, 2011 Share Posted September 22, 2011 Hi, How can i show image using absolute path instead of virtual path?? Help please Link to comment https://forums.phpfreaks.com/topic/247646-image-path/ Share on other sites More sharing options...
JonnoTheDev Posted September 22, 2011 Share Posted September 22, 2011 Separate the path into parts and take the bits you need i.e <?php $path = '/var/www/html/mywebsite/images/foobar.jpg'; $parts = explode('/', $path); $filename = $parts[count($parts)-1]; ?> <img src="/images/<?php echo $filename; ?>" /> Link to comment https://forums.phpfreaks.com/topic/247646-image-path/#findComment-1271716 Share on other sites More sharing options...
delickate Posted September 22, 2011 Author Share Posted September 22, 2011 Thanks neil, Images are not stored on root path. images are stored on different drives. i want to use path like this: d:/images/sani.gif Is it possible? Link to comment https://forums.phpfreaks.com/topic/247646-image-path/#findComment-1271718 Share on other sites More sharing options...
JonnoTheDev Posted September 23, 2011 Share Posted September 23, 2011 Images should be accessible via the document root for the domain i.e http://www.xyz.com/images/test.jpg Not stored on some random part of your hard disk on a windows pc. You should be running a webserver like Apache or IIS do define the document root for your website. To get an image to display that it outside of the document root you would either have to copy it into the doc root folder i.e images/ or, as long as it has sufficient permissions use php to display it using the following: <?php if($image = @fopen('d:\\images\\sani.gif', 'rb')) { header('Content-Type: image/gif'); fpassthru($image); } ?> Link to comment https://forums.phpfreaks.com/topic/247646-image-path/#findComment-1271976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.