gna*_*arf 6 html javascript flash file-upload google-gears
所以 - 我一直在使用这种文件上传方法,但似乎Google Gears对实现HTML5规范的新浏览器支持不足.我听说过几个频道的弃用词,所以我正在寻找能够完成以下任务并支持新浏览器的替代品.我总是可以回到齿轮/标准文件POST,但这些以下项目使我的过程更简单:
PUT请求而不是POST<button>单击时触发文件选择.我不确定新的HTML5浏览器是否支持桌面/请求对象齿轮使用,或者是否有闪存上传器具有我在谷歌搜索中缺少的这些功能.
使用齿轮上传代码的示例:
// select some files:
var desktop = google.gears.factory.create('beta.desktop');
desktop.openFiles(selectFilesCallback);
function selectFilesCallback(files) {
$.each(files,function(k,file) {
// this code actually goes through a queue, and creates some status bars
// but it is unimportant to show here...
sendFile(file);
});
}
function sendFile(file) {
google.gears.factory.create('beta.httprequest');
request.open('PUT', upl.url);
request.setRequestHeader('filename', file.name);
request.upload.onprogress = function(e) {
// gives me % status updates... allows e.loaded/e.total
};
request.onreadystatechange = function() {
if (request.readyState == 4) {
// completed the upload!
}
};
request.send(file.blob);
return request;
}
Run Code Online (Sandbox Code Playgroud)
编辑:显然flash无法使用PUT请求,因此我将其更改为"喜欢"而不是"必须".
(根据提问者的建议,源自对原始问题的评论。)
Plupload 是最新的产品之一,它使用可用的最佳方法(HTML 5、Flash、Gears、Silverlight):http://plupload.com/
| 归档时间: |
|
| 查看次数: |
978 次 |
| 最近记录: |