用户添加图像时的事件处理程序
我有一个表单,可以让用户上传自己的图像。我需要一个 jQuery 事件处理程序来处理上传输入的情况。
<script>
$('#imageFile').someeventhander(function(){do some work son!});
</script>
<input id="imageFile" type="file">
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">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个非常复杂的问题,因为在您提交表单之前文件输入不会上传。请参阅此相关问题:
如何异步上传文件?
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?
要上传文件,您需要服务器接受它并将响应发送回浏览器。然后 jQuery 可以使用响应来触发事件或调用函数。所以答案取决于您的服务器如何处理上传。
swfUpload 是一种流行的解决方案,它使用小型 Flash 影片来处理上传。它有一个 jQuery 插件,可以触发大量事件,允许您监视上传的开始/进度/错误/完成。
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.