제 3 자 플러그인을 사용하지 않고서도 이것은 사실적이며 가능합니다.
function processFileUpload(droppedFiles) {
// add your files to the regular upload form
var uploadFormData = new FormData($("#yourregularuploadformId")[0]);
if(droppedFiles.length > 0) { // checks if any files were dropped
for(var f = 0; f < droppedFiles.length; f++) { // for-loop for each file dropped
uploadFormData.append("files[]",droppedFiles[f]); // adding every file to the form so you could upload multiple files
}
}
// the final ajax call
$.ajax({
url : "upload.php", // use your target
type : "POST",
data : uploadFormData,
cache : false,
contentType : false,
processData : false,
success : function(ret) {
// callback function
}
});
}
: - 방법
드롭 영역
$(".drop-files-container").bind("drop", function(e) {
var files = e.originalEvent.dataTransfer.files;
processFileUpload(files);
// forward the file object to your ajax upload method
return false;
});
processFileUpload() :
다음 조각은 당신이 일할 수있는 방법에 대한 아이디어를 줄 것이다 양식 예시
시작 지점으로 자유롭게 사용하십시오. 이것의 브라우저 지원은 내가이 플러그인 센을했습니다 여기 http://caniuse.com/#feat=xhr2 당신이 진행 표시 줄, 미리보기, 애니메이션과 같은 원하는 엑스트라를 추가 할 수 있습니다 물론
...
섹션 설명을 해 주실 수 있습니까? if (droppedFiles.length> 0) { for (f = 0; f
Tenatious
@Tenatious 거기에 몇 가지 의견을 추가했습니다. 그러나 삭제 된 파일을 양식에 추가하는 일반적인 for-loop. – wildhaber
아하이 봐요. 나는 그걸 업로드 할 수 있었다. 도와 주셔서 감사합니다!:) – Tenatious