这近一直在做一个手机端稿件编辑功能,其中要上传文件到后台,之前在pc端已经完成了,但是是用的flash的上传组件。很早之前也听说html5可以用ajax上传文件了,于是百度了一下,找到了一个比较好用的,和大家一起分享一下。
html5uploader 一个js就搞定问题了(基于jqurey)。
http://www.igloolab.com/jquery-html5-uploader/
上面是下载地址,下载也比较麻烦,一定要用facebook分享之后才能下。
当然我也提供了下载资源给大家
http://download.csdn.net/download/jqriyv_wl/9579466
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.html5uploader.min.js"></script>
<script type="text/javascript">
$(function() {
$("#dropbox,#multiple").html5Uploader({
name: "foo",postUrl: "bar.aspx"
});
});
</script>
<div id="dropbox"></div>
<input id="multiple" type="file" multiple> 下面给出的是参数:
Settings name: upload field identifier. postUrl: the url to post the file data. onClientAbort: Called when the read operation is aborted. onClientError: Called when an error occurs. onClientLoad: Called when the read operation is successfully completed. onClientLoadEnd: Called when the read is completed,whether successful or not. This is called after either onload or onerror. onClientLoadStart: Called when reading the data is about to begin. onClientProgress: Called periodically while the data is being read. onServerAbort: Called when the post operation is aborted. onServerError: Called when an error occurs. onServerLoad: Called when the post operation is successfully completed. onServerLoadStart: Called when posting the data is about to begin. onServerProgress: Called periodically while the data is being posted. onServerReadyStateChange: A JavaScript function object that is called whenever the readyState attribute changes. The callback is called from the user interface thread. onSuccess: Called when the post operation is successfully completed,the ReadyState is 4 and the HttpStatus is 200. Useful to get back informations from the server.
回调方法的参数大家可以在下载的原码中查看。
好了,行动起来吧。 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|