开发者

how do i go about adding a picture to a form as a preview?

im working on a front page ad right now the ad page would display an image and some titles etc

in the background ive created a form for the user to change that image the image is then saved in the db as a blob(which im not sure about)

i would liek to be able to preview the picture the user after been uploaded

ive googled and have yet to find any answers and etc

any tips and help will be appreciated!!

<html>
<body>
<form action="">
<fieldset>
<l开发者_StackOverflow中文版egend>Personal information:</legend>
Name: <input type="text" size="30" /><br />
E-mail: <input type="text" size="30" /><br />
Date of birth: <input type="text" size="10" />
Picture: <input type="img" />
</fieldset>
</form>
</body>
</html>

I WILL NEED TO GENERATE THIS USING JAVASCRIPT, so how do i go about putting that picture in the form? and previewing it.


What browser support do you require? If it's ok for this feature (preview image upload) to only work in modern browsers (latest Firefox, Chrome, for example) you can try using the File API in HTML5.

FileReader examples

This is fun because you can read or present information about a file all on the client before you even upload it to the server.

If you have to support less-capable browsers in this feature, you're probably stuck with a solution where you upload the file using a XHR Post and then have your server return a URL to the image. Once upload is done, you can update an image source on your page dynamically, while staying on the same page.


<input type="file" name="img" />

http://www.cs.tut.fi/~jkorpela/forms/file.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜