Welcome Guest, Not a member yet? Register   Sign In
Problems with file:///
#1

[eluser]StraTDeS[/eluser]
Hi all:

First, sorry about my bad english, I am from Spain...

Well, now, I need your help: I am developing a web application and I need, in some place, to show an image from the hard disc. My idea is to show a thumbnail of and image after load it to the server. In order to make it, I tried to put:

Code:
<img src="file:///C:/photo.jpg" alt="photo" />

It works in IE6 but don't in IE7 and Firefox. I supose it's something about the routing functions of codeigniter. Any ideas?

Thank in advance.
#2

[eluser]RobbieL[/eluser]
I'm not going to be much help here, but I didn't relise you could access a users hard drive so easily like that. Was actually shocked to see that you said it works in IE6.
#3

[eluser]Alex007[/eluser]
[quote author="RobbieL" date="1194991236"]I'm not going to be much help here, but I didn't relise you could access a users hard drive so easily like that. Was actually shocked to see that you said it works in IE6.[/quote]

You're not accessing the user's hard drive, his broswer is accessing his own hard drive.

And yes it's been disabled in recent browsers as a security flaw (hard to exploit, but still).

I think your basic concept is flawed, you shouldn't display image from the users hard drive, what if he doesn't have a C:\ drive, what if he's on linux ?

Let him upload the file on the server and display is from the server.
#4

[eluser]ELRafael[/eluser]
Hey, first of all, Bienvenido (sorry about spain, i'm from brazil)

Man, it's not a CodeIgniter problem. After ie6, you can't access local files anymore.

Firefox denies too.

What you can do, if you wanna show the local image to user, search for action script (prefer version no.3). You can use the webcam too.

But in PHP i don't know. You need to upload image to server before show it to user.

Good luck!
#5

[eluser]StraTDeS[/eluser]
Hi:

First all thank for all the answers.

By parts: When I say C: I spoke about a know url that can be C: or D: or /etc/ or anything else. I can know that this url exists and the file exists too.

About the security limitation, if you try to put this code in a normal web page (out of codeigniter), it works in all browsers. Try this:

Code:
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <img src="file:///C:/image.jpg" alt="Just a test" />
&lt;/body&gt;
&lt;/html&gt;

If you put an image named image.jpg in C:, firefox and IE 7 will show you the image. Tested!

Anymore ideas?

Thank you!
#6

[eluser]ELRafael[/eluser]
Hey, but how you tested???

file:///C:/test.html in the browser ow www.domain.com/test.html???

For sure, the first option will work fine. But a web page access a local file "without user permission" i still don't believe, sorry
#7

[eluser]Michael Wales[/eluser]
This would have absolutely nothing to do with CI - your essentially not even using CI for this.

Test:
Make a new .html document on your webserver and place the exact same img tag - you'll find it doesn't work in the same manner.

It basically comes down to the security settings of the browser - drop those (or a little yellow bar should appear at the top of the page) and tell it to allow the site to access your hard drive.
#8

[eluser]StraTDeS[/eluser]
Oh, yeah, it's right. I tested it from hard drive.

Then, any idea about how to make it? I won't upload the file to make the thumb, because it's possible that someone upload the photo but not insert data in the form. I am going to explain the idea:

I have a info form and in the same form the user can select photos for be uploaded. All at time. If the user select an image from hard drive, I want that the input type="file" become a thumb of the image, all in time with ajax. But if the image go to the server, the user can close the browser and not insert the info. Then, the photo will remain in the server with no associated information. I am not sure if you'll answer me :S

Greetings!
#9

[eluser]ELRafael[/eluser]
Man!!!!

Why you can do this:

- Fill the information. After filled, upload the image.

If you need the both (image + data), you check if the any field is empty. If data empty, just erase the record and don't show the upload form. If the user don't upload the image, delete the reg.

In this way, when the user upload something, you'll have the data from that image. And if not, you won't have the image in your server.

Sorry about my english..... I drunk too much yesterday and tomorrow is holiday!!!!
#10

[eluser]StraTDeS[/eluser]
Well, basically the problem is that the user can close the browser and don't upload the form. The case is for example:

I take an image, I upload it to the server, and I close the form. No data, but there is an image.

Thank!




Theme © iAndrew 2016 - Forum software by © MyBB