AJAX 및 HTML5를 사용하여 클라이언트 컴퓨터에서 서버의 폴더로 파일 업로드를 처리하려고합니다.AJAX/HTML 5 파일 업로드
사용자가 컴퓨터에서 파일을 찾아 볼 수있는 지점에 있습니다. upload
버튼을 클릭하면 파일 업로드를 완료하는 데 필요한 스크립트를 실행한다고 가정합니다. upload.php
스크립트를 사용하여이 파일 업로드 기능의 기능을 계속 코딩하는 방법을 모르겠습니다.
제 질문은 서버의 폴더가 docs
이라고 가정합니다. 사용자가 업로드 버튼을 클릭 한 후 사용자가 선택한 파일을 서버 docs
폴더로 다운로드하려면 어떻게해야합니까?
의견을 보내 주시면 감사하겠습니다.
미리 감사드립니다.
JQuery와
$.ajax({
url: 'upload.php', //server script to process data
type: 'POST',
xhr: function() { // custom xhr
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload
}
return myXhr;
},
//Ajax events
success: function(data){
alert("OK");
$('body').html(data);
},
// Form data
data: formData,
//Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: false,
processData: false
});
HTML
<form enctype="multipart/form-data">
<input name="file" type="file" />
<input type="button" value="Upload" />
</form>
<progress></progress>
후 다음을 추가하십시오이 나에게 무리 도움 : http://net.tutsplus.com/tutorials/javascript-ajax/uploading-files-with-ajax/ –
I 너무 오래 전에 당신과 비슷한 문제를 겪었습니다. 그러나, 나는 정말 그것을 망쳐 놓고 싶지 않았기 때문에, 나는이 확장을 사용했다. https://github.com/blueimp/jQuery-File-Upload 작고 설정이 쉽고 설정하기 쉽다. 그냥 제안. – GJK