开发者

Event handler for when a user has added an image

I have a form that lets users upload a image of them self. I need an jQuery event handler for when the input in uploaded.

<script>
  $('#imageFile').someeventhander(function(){do some work son!});
<开发者_运维知识库/script>

<input id="imageFile" type="file">


This is a very complex problem, as file inputs do not upload until you submit a form. See this related question:

How can I upload files asynchronously?


To upload a file you need the server to accept it and send a response back to the browser. jQuery can then use the response to trigger an event or call a function. So the answer depends on how your server is handling the upload.

swfUpload is a popular solution that uses a small Flash movie the handling the uploading. There is a jQuery plugin for it that triggers numerous events that allow you to monitor start/progress/error/completion of the upload.


$('#imageFile').change I believe is what I needed.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜