This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes image preview Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "image preview" Watch "image preview" New topic
Author

image preview

sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186


By using this i will get a browse box and a browse button . the moment i browse the image , i will get the path in the browse box.

what i want is the moment the path comes in the area then automatically the preview of the image should come in the specified area or there itself. how can i do it. i 've got few scripts in net but they are of no use. i am using firefox.

i want to see the preview of the image before i upload it to the database.

-thank you


"SCJP5 | SCWCD5| DEVELOPER"
ramnna jain
Ranch Hand

Joined: Mar 16, 2009
Posts: 129

sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186
Thank you , but its not working. it is giving a blank box.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

sasank manohar wrote:Thank you , but its not working. it is giving a blank box.

It would be helpful is you were to post what the src is being set to.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
off the bat ... try this;



Also, in above code, did you ensure that you're getting the "file" when you click on it? because on the snippet provided to you above I see that file path is non-relative ...

Trilochan
sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186
First of all i apologize for my very late response , what can i do , life is like that...hectic.

thank you ramnna and trilochan for your inputs.

i am trying to upload images from

C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\winter.jpg

but next time it can be D:\wallpapers\xyz.jpg or gif
so how can i give path, because image loading will be done by the user/client , so path is not in our hands.

the following code , tried individually didnot work.


also this as i already told you didn't work, its just giving blank box with specified sizes.


the html is ,




any help would be appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
I don't think that JavaScript has access to the contents of a file upload field for security reasons, so this may not be possible.


Ping & DNS - my free Android networking tools app
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is impossible to do it with today's browser security settings. If you want to do a preview you need to use Flash or an Applet OR upload it to a temp section on your server.

Eric
sasank manohar
Ranch Hand

Joined: Feb 14, 2008
Posts: 186
thank you ulf and eric.

is it possible with ajax ? I heard that it is possible with ajax, so how much is it true ?please tell me.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Ajax == JavaScript == Nope
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: image preview
 
Similar Threads
Action in a New Windows FormFile NULL
Display jpeg file in jsp page
Preview image through XML Schema
How browse a URL from local disk
creating a Browse folder dialog box using applet