Faked path - Smartphone.

M

Mr. X.

Hello.
When I do something like this:
<input type="file" accept="image/*" capture ></input>

I can attach a picture or camera on smartphones.

This all fine,
but what if I want to show the picture to the user who choose it.
I created for that a <div> element and try to set the background-image to
the file (which is on local computer or on local smarphone) -

Then I got the path of :
c:/fakepath/myfile.jpg.

How can I solve the problem?
The fake path - I cannot use as reference, and I don't know if I get instead
of the path the image source in bits (so I can do something like
data:image/png;base64,... a binary data ....)

Thanks :)
 
B

Ben Bacarisse

Mr. X. said:
Hello.
When I do something like this:
<input type="file" accept="image/*" capture ></input>

I can attach a picture or camera on smartphones.

This all fine,
but what if I want to show the picture to the user who choose it.
I created for that a <div> element and try to set the background-image

Why use a background image?
to the file (which is on local computer or on local smarphone) -

Then I got the path of :
c:/fakepath/myfile.jpg.

How can I solve the problem?
The fake path - I cannot use as reference, and I don't know if I get
instead of the path the image source in bits (so I can do something
like data:image/png;base64,... a binary data ....)

Yes, many browsers support these data pseudo-URLs in the src attribute
of an img element. I have not used them is CSS, but I think support is
limited.
 
M

Mr. X.

Found:
http://saravani.wordpress.com/2012/03/14/preview-of-an-image-before-it-is-uploaded/
That's solved my problem.

BTW - As the above problem - how can I know also which width+height are
related to the image?

Thanks, anyway.

"Ben Bacarisse" wrote in message

Mr. X. said:
Hello.
When I do something like this:
<input type="file" accept="image/*" capture ></input>

I can attach a picture or camera on smartphones.

This all fine,
but what if I want to show the picture to the user who choose it.
I created for that a <div> element and try to set the background-image

Why use a background image?
to the file (which is on local computer or on local smarphone) -

Then I got the path of :
c:/fakepath/myfile.jpg.

How can I solve the problem?
The fake path - I cannot use as reference, and I don't know if I get
instead of the path the image source in bits (so I can do something
like data:image/png;base64,... a binary data ....)

Yes, many browsers support these data pseudo-URLs in the src attribute
of an img element. I have not used them is CSS, but I think support is
limited.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top