0
因此,我最近遇到了一個問題,那就是當我嘗試在Firefox中上傳文件時,它會被重置。我已經在Chrome中測試過這個功能,並且它可以很好地工作,但它在Firefox中不起作用。看着螢火蟲控制檯日誌沒有給我任何線索,它重置。我正在使用resumable.js JS庫將我的上傳與PHP後端分塊。這在Chrome中100%有效。頁面在Firefox中發生事件後重置頁面
當我點擊調用resume.upload()
方法的上傳按鈕時,會發生這種情況,一旦它發生,它會重置幀,以使上傳不通過。 如果我添加在哪裏調用此方法斷點,並讓它通過跨過它執行一次,它工作正常,但如果我讓他走,它只是重置
JS的小片段和HTML:
<form>
<input id="showBrowse" style="margin-right:5px;" type="file">
<button id="uploadFileBTN" style="margin-left:25px" onclick='resume.upload()'>Start Upload</button>
<br>
<span style="margin-right:3px;margin-right:10px;" id="pauseOrplay"></span><img id='pauseDL' onclick='resume.pause();paused();' alt="Pause">
<span style="margin-left:23px;margin-right:10px;" id="cancelTXT"></span><img id='cancelDL' onclick='resume.cancel();cancel();' alt="Cancel">
<br>
<input type="checkbox" id="overwriteFile" onclick='overwriteIt()'>Overwrite if file already exists <br>
<input type="hidden" value="<%=view.getUID()%>" id="hiddenUID">
</form>
這裏是JS實現
/**
* Resumable.js implementation
*/
$("#stitchLabel").hide();
resume = new Resumable({
target:uploadURL,
query:{rewrite: $("#overwriteFile").attr('checked')?true:false},
resumableChunkSize:1*1024*1024,
simultaneousUploads:1,
testChunks:false
});
if(!resume.support){
hidePauseAndCancel();
$("#showBrowse").hide();
$("#uploadFileBTN").hide();
alert("Sorry! The upload file feature is not supported on your browser. Please use Firefox 4+, Chrome 11+, or Safari 6+");
}
resume.assignBrowse(document.getElementById("showBrowse"));
resume.on('fileAdded',function(file){
var idFile = file.uniqueIdentifier;
$("#fileBlock").append("<li id='"+file.uniqueIdentifier+"'>"+file.fileName+" <span id='fileProgress'><b>Waiting for upload to start</b></span></li>");
$("#uploadFileBTN").attr('disabled',false);
$("#overwriteFile").attr('disabled',true);
$("#pauseDL").hide();
$("#resumeDL").hide();
$("#pauseOrplay").hide();
});
resume.on('fileSuccess',function(file, message){
alert("finished");
var name = file.fileName;
$("#fileBlock").find("#"+file.uniqueIdentifier).remove();
$("#userFiles").children().find("img#pauseDL").remove();
$("#userFiles").children().find("img#resumeDL").remove();
$("#fileBlock").children().find("#"+file.uniqueIdentifier).css('color',"#D4D4D4");
$("#fileBlock").find("#wait").show();
hidePauseAndCancel();
if(($("#fileBlock").find("#wait")).length == 0){
$("#fileBlock").append("<b id='wait'>Stitching... don't press cancel</b>");
}
});
resume.on('fileProgress', function(file){
if(resume.progress()*100>0){
$("#pauseDL").attr('src','/img/IMGS/icons/pause.png').show();
$("#pauseOrplay").html("<b>Pause</b> ");
$("#pauseOrplay").show();
$("#cancelTXT").html("<b>Cancel</b>");
}
$("#cancelDL").attr('src','/img/IMGS/icons/delete-icon.png').show();
$("#cancelTXT").html("<b>Cancel</b>");
$("#cancelTXT").show();
$("#uploadFileBTN").attr('disabled',true);
$("#fileBlock").find("#"+file.uniqueIdentifier).find("#fileProgress").html(" <b>"+Math.floor(file.progress()*100)+"%</b>").css('color','#05AD24');
$("#overwriteFile").attr('disabled',true);
});
螢火蟲給出任何消息都沒有。有什麼我使用的FF不支持? FF v20順便說一句。