2017-11-21 1 views
0

드롭 존으로 ZIP 압축 파일을 업로드해야합니다. 압축 파일을 선택할 때 진행률 막대가 0에서 100까지 표시되지만 요청은 서버에 도달하지 않습니다. 제 형태로는 결코 호출되지 않습니다.Dropzone.js는 .zip 파일을 업로드하지 않습니다.

if (Request.Files != null && Request.Files.Count > 0) 
    { 
     if (Request["type"]=="zip" && (Request.Files[0].ContentType == "application/x-compressed" || Request.Files[0].ContentType == "application/x-zip-compressed" || Request.Files[0].ContentType == "application/zip" || Request.Files[0].ContentType == "multipart/x-zip")) 
     uploadZip(); 
    } 
: 이것은 파일 형식을 확인 내 행동의 코드가

Dropzone.options.dropzoneZip = { 
     dictDefaultMessage: "Drag files here o click to upload", 
     maxFiles: 1, 
     acceptedFiles: ".zip", 
     init: function() { 
      this.on("error", function (file, errorMessage) { 
       alert("error : " + errorMessage); 
      }); 
      this.on("addedfile", function (e) { 
       var n = Dropzone.createElement("<a href='javascript:;' class='btn red btn-sm btn-block'>Remove</a>"), 
        t = this; 
       n.addEventListener("click", function (n) { 
        n.preventDefault(), n.stopPropagation(), t.removeFile(e) 
       }), e.previewElement.appendChild(n) 
      }), 
      this.on("complete", function (data) { 
       if (data.xhr.responseText == "success") { 
        swal({ 
         title: 'Success', 
         text: 'File uploaded', 
         type: "success" 
        }).then(
        function() { 
         $(".se-pre-con").fadeIn("slow"); 
         location.reload(); 
        }) 
       } 
      }), 
      this.on('error', function (file, errorMessage) { 
       if (errorMessage != "success") { 
        var errorDisplay = document.querySelectorAll('[data-dz-errormessage]'); 
        errorDisplay[errorDisplay.length - 1].innerHTML = errorMessage; 
       } 
       else if (errorMessage.indexOf('404') !== -1) { 
        var errorDisplay = document.querySelectorAll('[data-dz-errormessage]'); 
        errorDisplay[errorDisplay.length - 1].innerHTML = 'Error 404: The upload page was not found on the server'; 
       } else if (errorMessage.indexOf('500') !== -1) { 
        var errorDisplay = document.querySelectorAll('[data-dz-errormessage]'); 
        errorDisplay[errorDisplay.length - 1].innerHTML = 'Error 500: Internal server error'; 
       } 
      }); 
     } 
    } 

입니다 : 이것은 내 JS 코드가

<form action="URL_ACTION" class="dropzone dropzone-file-area" id="dropzoneZip" method="post" enctype="multipart/form-data"> 
    <div class="fallback"> 
    <input name="file" type="file" /> 
    <input type="submit" value="Upload" name="upload" /> 
    </div> 
</form> 

입니다 : 이 내 페이지에서 파일 업 로더입니다

하지만이 작업에는 절대로 도달하지 않습니다. 같은 방법으로 이미지를 업로드하려고했는데 정상적으로 작동합니다. 난 당신이 xamp/uniserver 후 완전 내가 테스트 한 작업 위의 코드가 있다면 내가

<?php 
$ds   = DIRECTORY_SEPARATOR; //1 

$storeFolder = 'uploads'; //2 

if (!empty($_FILES)) { 

    $tempFile = $_FILES['file']['tmp_name'];   //3    

    $targetPath = dirname(__FILE__) . $ds. $storeFolder . $ds; //4 

    $targetFile = $targetPath. $_FILES['file']['name']; //5 

    move_uploaded_file($tempFile,$targetFile); //6 

} 
?>  

update.php 잘못

답변

0

index.html을

<html> 

<head> 
<script 
    src="https://code.jquery.com/jquery-3.2.1.js" 
    integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" 
    crossorigin="anonymous"></script> 
<!-- 1 --> 
<link href="dropzone.css" type="text/css" rel="stylesheet" /> 

<!-- 2 --> 
<script src="dropzone.min.js"></script> 
<style> 
    .dropzone .dz-preview { 
     display:none; 
    } 

</style> 
</head> 

<body> 


<form action="upload.php" class="dropzone dropzone-file-area" id="dropzoneZip" method="post" enctype="multipart/form-data"> 
    <div class="fallback"> 
    <input name="file" type="file" /> 

    </div> 
</form><input type="submit" value="Upload" name="upload" id="submit-all" /> 

<script> 

Dropzone.options.myDropzone = { 

    // Prevents Dropzone from uploading dropped files immediately 
    autoProcessQueue: false, 

    init: function() { 
    var submitButton = document.querySelector("#submit-all") 
     myDropzone = this; // closure 

    submitButton.addEventListener("click", function() { 
     myDropzone.processQueue(); // Tell Dropzone to process all queued files. 

    }); 

    // You might want to show the submit button only when 
    // files are dropped here: 
    this.on("addedfile", function() { 
     // Show submit button here and/or inform user to click it. 

    }); 

    } 
}; 
</script></body></html> 

을 뭘하는지 알아낼 수 없습니다 서버에있는 파일을 업로드 할 장소의 업로드 폴더 만들기

+0

죄송합니다. ASP.NET을 사용하고 있다고 지정해야했습니다. 아이디어가 있다면 어떤 제안이라도 열려 있습니다. –

0

좋아, 왜 업로드했는지 알아 냈어. 최대 파일 크기가 maxRequestLength를 초과했습니다. Web.config 파일의 ameter. 작은 파일을 업로드하면 올바르게 작동합니다.

관련 문제