开发者

displaying image after Choose File, before upload

how can after choose image and before upload (before insert in database) displaying image?

this code not displaying image:

var a = $('<img src="' + g.STRING.selected.replace('$file', v) + '" alt="A开发者_JAVA技巧ngry face" width="50" height="50" />'),

<input type="file" name="image' >

With respect


I think you can check this tutorial (look at the "New hotness" section) for a jQuery solution


You can use the HTML5 File API (tutorial) to display the selected file. The best way is probably to use a FileReader to get a dataURL of the file and assign it to a src of an img.


There are Many JavaScript functions written out there to render an image on the page using response.write and these methods all you have to do is search the Google.

but why you want to do a client side display ? even yahoo or many famous site do not handle rendering image in this way... they upload an image in a temporary database and if the user confirms it will be copied in the permanent database.

without server side verification you need many lines of java script code that may behave differently in different browsers.

hope i helped you a bit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜