2017-10-17 3 views
0

작업은 브라우저에서 파일을 만든 다음 서버에 업로드하는 것입니다. 블롭 객체를 생성하고 브라우저에 파일 객체를 생성 한 다음 서버에 업로드합니다.사파리에서 파일 개체를 서버에 업로드 할 수 없습니다.

var file = [new File([data],'-Invoice.pdf', {type: 'application/pdf;charset=utf-8;'})]; 

파일이 사파리에서 생성되었지만 업로드를 요청하면 서버에서 404 i-e 파일을 찾을 수 없음 오류로 응답합니다. Chrome/firefox에서 완벽하게 작동합니다. 서버 측에서 npm 모듈 express-fileupload를 사용했습니다. 도와주세요

답변

0

브라우저의 차이가 서버 측 업로드에 영향을 미치지 않아야합니다. 서버로 전화를 걸면 파일이 있는지 다시 한 번 확인해야합니다.

파일 업로드 버튼을 사용하지 않았다고 가정합니다. 업로드를 위해 html 지침을 따르십시오. Safari에서 테스트하지는 않았지만 작동해야합니다.

$scope.upload = function (file) { 
console.log(file.length); // if less than 1 or undefined, then your problem is probably in the html. I 
    Upload.upload({ 
     url: 'upload/url', 
     data: {file: file, 'username': $scope.username} 
    }).then(function (resp) { 
     console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data); 
    }, function (resp) { 
     console.log('Error status: ' + resp.status); 
    }, function (evt) { 
     var progressPercentage = parseInt(100.0 * evt.loaded/evt.total); 
     console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name); 
    }); 
}; 
+0

이미 시도했지만 문제가 여전히 있습니다. –

관련 문제