이제 파일 업로드 작업을하고 있습니다. 그래서 아약스 호출을 사용하여 코드 조각을 작성했습니다. 내 로컬 서버에서 파일 (GB)을 업로드 할 때이 작업이 완벽하게 작동합니다.대용량 파일 업로드 ajax 호출을 통해 실패했습니다.
$.ajax({
type: "POST",
url: "process/uploadFlatFile.htm",
enctype : 'multipart/form-data',
//timeout: 0,
crossDomain: true,
data : formData,
processData: false,
contentType: false,
cache: false,
dataType: 'json',
xhr: function() {
myXhr = $.ajaxSettings.xhr();
//myXhr = new XMLHttpRequest();
console.log("myXhr: " + myXhr.upload);
if(myXhr.upload){
console.log("adding progress event listener");
myXhr.upload.addEventListener('progress', showProgress, false);
} else {
console.log("Upload progress is not supported.");
}
return myXhr;
},beforeSend: function(xhr, opts) {
console.log("beforeSend:xhr: " + xhr + ", opts: " + opts);
currXhr = xhr;
showProgressBar();
status.empty();
var percentVal = '0%';
bar.width(percentVal);
percent.html(percentVal);
$(cancelSelector).removeAttr('disabled');
},
success: function(result,status,xhr) {
console.log("success:result: " + result);
console.log("success:status: " + status);
console.log("success:xhr: " + xhr);
var percentVal = '100%';
bar.width(percentVal);
//$("#fountainGG").hide();
percent.html(percentVal);
$.unblockUI({
onUnblock: function(){
if(result=="success"){
console.log("SUCCESS PART :")
alertMessage("Success","File Uploaded Successfully","info");
setTimeout(function(){
window.location.href = "processFlow.htm";
//newProcessClicked('yes'); closeConDiv()
}, 2000);
}else{
alertMessage("Error","Error in upload. Try Again !","info");
}
}
});
},
complete: function(xhr,status){
console.log("COMPLETE PART :")
console.log("complete:status: " + status + ", xhr: " + xhr);
$('#btnGoUpload').prop('disabled', false);
},
error: function(xhr, statusText, err) {
$.unblockUI();
console.log("statusText: " +statusText);
console.log("error: " + err);
var msg = "Error in uploading file. Try Again !";
if (err == "abort"){
msg = "File upload aborted.";
}
alertMessage("Error",msg,"info");
}
});
하지만 공용 서버에서 파일 (30 기가 이상) GB를 업로드하고 때 시간이 몇 후 아약스 호출의 일부 에러거야. 연결 시간 제한 문제라고 생각합니까? 연결 시간 제한 문제가 있다면 어떻게 해결할 수 있습니까?
ini_set('max_execution_time', 0);
는 당신이 필요로하는, 그 또한 당신을 차단할 수 있습니다, 최대 업로드 크기를 늘리려면 :
'아약스 호출 중 오류 부분'으로 이동하면 어떤 오류가 기록됩니까? 즉, statusText와 err은 무엇입니까 –
statusText에 '오류'가 표시됩니다. – user3159781
오류 란 무엇입니까? –