How to retrieve and show images from another drive using src attribute in tag?
up vote
-1
down vote
favorite
<img src="d:/Tulips.jpg" >
</img>
<img src="file:///d:Tulips.jpg">
How to retrieve and show images from another drive using src attribute in <img>
tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.
php html image
add a comment |
up vote
-1
down vote
favorite
<img src="d:/Tulips.jpg" >
</img>
<img src="file:///d:Tulips.jpg">
How to retrieve and show images from another drive using src attribute in <img>
tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.
php html image
2
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
<img src="d:/Tulips.jpg" >
</img>
<img src="file:///d:Tulips.jpg">
How to retrieve and show images from another drive using src attribute in <img>
tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.
php html image
<img src="d:/Tulips.jpg" >
</img>
<img src="file:///d:Tulips.jpg">
How to retrieve and show images from another drive using src attribute in <img>
tag?
If the image is in the same folder it works but when the source of the image is on another drive it's not working.
php html image
php html image
edited Apr 4 '14 at 8:29
Shankar Damodaran
59.7k1267109
59.7k1267109
asked Apr 4 '14 at 6:44
shwe45
812
812
2
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49
add a comment |
2
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49
2
2
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
jpgYou can't put your file system path in the src
unless you open it from your desktop or your computer. You can try to pass the file as base64
encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP
$image = file_get_contents('d:/Tulips.jpg');
$image_codes = base64_encode($image);
And in your html put it like this.
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create animage upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use.htaccess
to restrict direct access to your image folder.
– Shankar Damodaran
Apr 4 '14 at 7:24
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to useRAID
but expensive. Or you can upload to both your webroot as the primary storage andd:
as backup. I've edited my answer. Should work now.
– iamsleepy
Apr 4 '14 at 7:33
|
show 3 more comments
up vote
1
down vote
Try
<img src="file:///d:/Tulips.jpg">
You were missing a slash after your drive lettter.
2
still its not working
– shwe45
Apr 4 '14 at 6:52
add a comment |
up vote
0
down vote
The reason is you are doing the inevitable.
HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.
Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
jpgYou can't put your file system path in the src
unless you open it from your desktop or your computer. You can try to pass the file as base64
encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP
$image = file_get_contents('d:/Tulips.jpg');
$image_codes = base64_encode($image);
And in your html put it like this.
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create animage upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use.htaccess
to restrict direct access to your image folder.
– Shankar Damodaran
Apr 4 '14 at 7:24
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to useRAID
but expensive. Or you can upload to both your webroot as the primary storage andd:
as backup. I've edited my answer. Should work now.
– iamsleepy
Apr 4 '14 at 7:33
|
show 3 more comments
up vote
2
down vote
accepted
jpgYou can't put your file system path in the src
unless you open it from your desktop or your computer. You can try to pass the file as base64
encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP
$image = file_get_contents('d:/Tulips.jpg');
$image_codes = base64_encode($image);
And in your html put it like this.
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create animage upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use.htaccess
to restrict direct access to your image folder.
– Shankar Damodaran
Apr 4 '14 at 7:24
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to useRAID
but expensive. Or you can upload to both your webroot as the primary storage andd:
as backup. I've edited my answer. Should work now.
– iamsleepy
Apr 4 '14 at 7:33
|
show 3 more comments
up vote
2
down vote
accepted
up vote
2
down vote
accepted
jpgYou can't put your file system path in the src
unless you open it from your desktop or your computer. You can try to pass the file as base64
encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP
$image = file_get_contents('d:/Tulips.jpg');
$image_codes = base64_encode($image);
And in your html put it like this.
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
jpgYou can't put your file system path in the src
unless you open it from your desktop or your computer. You can try to pass the file as base64
encoded strings. I'm showing how to do it in PHP because you tagged this question with PHP
$image = file_get_contents('d:/Tulips.jpg');
$image_codes = base64_encode($image);
And in your html put it like this.
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
edited Apr 4 '14 at 7:30
answered Apr 4 '14 at 7:00
iamsleepy
51037
51037
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create animage upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use.htaccess
to restrict direct access to your image folder.
– Shankar Damodaran
Apr 4 '14 at 7:24
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to useRAID
but expensive. Or you can upload to both your webroot as the primary storage andd:
as backup. I've edited my answer. Should work now.
– iamsleepy
Apr 4 '14 at 7:33
|
show 3 more comments
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create animage upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use.htaccess
to restrict direct access to your image folder.
– Shankar Damodaran
Apr 4 '14 at 7:24
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to useRAID
but expensive. Or you can upload to both your webroot as the primary storage andd:
as backup. I've edited my answer. Should work now.
– iamsleepy
Apr 4 '14 at 7:33
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
Thnk u for u answers....But it not showing image , it showing some code like this data:image/jpg;base64, /9j/4AAQSkZJRgABAgEAYABgAAD/4RKGRXhpZgAATU0AKgAAAAgABwEyAAIAAAAUAAAAYkdGAAMAAAABAAQAAEdJAAMAAAABAD8AAIKYAAIAAAAWAAAAdpydAAEAAAAcAAAAAOocAAcAAAfSAAAAAIdpAAQAAAABA
– shwe45
Apr 4 '14 at 7:07
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
@shwe45, Btw, am just curious why you want to read it from disk ? It will definitely wont work when you are moving it to a live server as you know all the paths will become invalid
– Shankar Damodaran
Apr 4 '14 at 7:17
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
i am working on one project, it is fully based on images uploading and many things, that whole project i am putting in C folder, but i feel that images are not safe there. i stored all uploaded images to another folder then, i got problem in displaying images..
– shwe45
Apr 4 '14 at 7:21
Nah, why don't you create an
image upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess
to restrict direct access to your image folder.– Shankar Damodaran
Apr 4 '14 at 7:24
Nah, why don't you create an
image upload
folder where you are running the script from ? If you are worried about the security of your images , then you can use .htaccess
to restrict direct access to your image folder.– Shankar Damodaran
Apr 4 '14 at 7:24
1
1
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use
RAID
but expensive. Or you can upload to both your webroot as the primary storage and d:
as backup. I've edited my answer. Should work now.– iamsleepy
Apr 4 '14 at 7:33
I think what @ShankarDamodaran suggested was better. If you are worried of crashing disk. You can try to use
RAID
but expensive. Or you can upload to both your webroot as the primary storage and d:
as backup. I've edited my answer. Should work now.– iamsleepy
Apr 4 '14 at 7:33
|
show 3 more comments
up vote
1
down vote
Try
<img src="file:///d:/Tulips.jpg">
You were missing a slash after your drive lettter.
2
still its not working
– shwe45
Apr 4 '14 at 6:52
add a comment |
up vote
1
down vote
Try
<img src="file:///d:/Tulips.jpg">
You were missing a slash after your drive lettter.
2
still its not working
– shwe45
Apr 4 '14 at 6:52
add a comment |
up vote
1
down vote
up vote
1
down vote
Try
<img src="file:///d:/Tulips.jpg">
You were missing a slash after your drive lettter.
Try
<img src="file:///d:/Tulips.jpg">
You were missing a slash after your drive lettter.
answered Apr 4 '14 at 6:50
stealthyninja
9,475103947
9,475103947
2
still its not working
– shwe45
Apr 4 '14 at 6:52
add a comment |
2
still its not working
– shwe45
Apr 4 '14 at 6:52
2
2
still its not working
– shwe45
Apr 4 '14 at 6:52
still its not working
– shwe45
Apr 4 '14 at 6:52
add a comment |
up vote
0
down vote
The reason is you are doing the inevitable.
HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.
Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.
add a comment |
up vote
0
down vote
The reason is you are doing the inevitable.
HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.
Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.
add a comment |
up vote
0
down vote
up vote
0
down vote
The reason is you are doing the inevitable.
HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.
Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.
The reason is you are doing the inevitable.
HTML markups cannot read data from the local disk drives, you need to put them in a folder or access it from the same directory for this to work.
Since, when you publish your website images are to be accessed from the folders of your webserver, accessing from a hard-drive directly (not possible via HTML though) puts you under potential risks.
edited Apr 4 '14 at 7:18
answered Apr 4 '14 at 7:06
Shankar Damodaran
59.7k1267109
59.7k1267109
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22855443%2fhow-to-retrieve-and-show-images-from-another-drive-using-src-attribute-in-img%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Show us what you've tried and give examples of it working and not working.
– Jeff
Apr 4 '14 at 6:44
<img src="tulips.jpg"> then it will show the image, but when i place my image in another drive and <img src="d:/Tulips.jpg"> it s not showing anything
– shwe45
Apr 4 '14 at 6:49