You can't without making a round trip to the server to upload the file. You cannot read it directly on the client system and display it on the page.
You will need to submit the multi-part form back to the server, write the file to the file system (or db if that's the way you want to go), and return a page (can be the same page) with an image tag that references the newly uploaded image. [ April 21, 2005: Message edited by: Bear Bibeault ]
Life called,so here I am.<br />Cheers<br />Niki.:-)
i think if the image file is on the client itself then you can use divs or layers depending on the browser to open these images.
Umm, sorry. No, you can't.
Originally posted by Amba Joshi: I have a file browse button in my jsp,
-I am supposed to click on the browse button -Select a file, the file is a picture (jpeg file) -I want it to be displayed in the page, as soon as I select it.
Any clue, how to do this ?
Do you only want the user to be able to see pictures on their own machine? Or did you want them to go to the server so everyone can see them?
Originally posted by Bear Bibeault: Hmmm, according to most references, it isn't allowed. And I couldn't get it to work. Strange and bears further investigation!
Probably because you weren't using a browser that tries to think for you. I got it to work in Mozilla on an FC2 box by adding IDs to the elements so that getElementById would work and by prepending the protocol ("file:") to that path so that it wouldn't be seen as a relative link in a *nix system. I'm curious to know if this works in Safari (I would applaud them if it didn't):
On the Mac, Mozilla 1.6 didn't display any error, but aborted the function at the same point. Safari threw a security exception. And interestingly enough, Mac IE (it's been a while since I've fired that relic up!) also did not allow it.
So this seems like a security hole specific to Windows IE, and perhaps whatever configuration of Mozilla Ben got it work under. [ April 22, 2005: Message edited by: Bear Bibeault ]
I guess there is no harm in being able to read the value. MSIE sends the whole path with the filename anyway. Choosing the file is something that the user has to do manually so it wouldn't be possible to use this to go snooping around someone's machine.
[ April 22, 2005: Message edited by: Ben Souther ] [ April 22, 2005: Message edited by: Bear Bibeault ]
According to what I read (I'm trying to find it again -- I looked it up from home this morning, pre-caffeine, so no bets) it's not necessarily the reading that's the violation, but the local referencing. In any case, since the "feature" depends upon a fluke (or bug or flaw or however you want to categorize it) that is inconsistent across browsers and platforms (and subject to removal/fixing in future versions), it's certainly not behavior I'd use in my app.
You did read all the posts in this thread, didn't you? It doens't work in half the browser/OS combinations tried AND it doesn't work because the technique used is specifically forbidden for security reasons.
Are you really going to put this in your app, knowing that? [ April 22, 2005: Message edited by: Ben Souther ]