2016-11-24 3 views
1

파일을 업로드 할 때 파일 이름이 반환되지만 모든 파일 이름을 배열에 저장하고 PHP 양식에 첨부하려고합니다. 이것은 내가 지금까지 가지고있는 것이다.업로드 된 파일을 배열에 저장

this.on("success", function(file, res) { 
     console.log(res.path); 
     file.newFileName = res; 
     $path = res.path; 

     // Create a hidden input to submit to the server: 
    $("#image").append($('<input type="hidden" ' +'name="files[]" ' +'value="' + res.path + '">')); 

     }); 

그리고 난 php 형식입니다. 하나의 파일 이름에 대해 작동하지만 현재 파일 이름 만 저장합니다.

{!! Form::hidden('image', '', array('id' => 'user-image')) !!} 

답변

0

코드가 완벽합니다. 나는 왜 당신 편이 아닌지 이해하지 못합니다.

이것은 나를 위해 실행되는 샘플 코드입니다.

 Dropzone.options.myDropzone = { 
      paramName: "product_image", 
      addRemoveLinks: true, 
      success: function (file, response) { 
       var obj = JSON.parse(response); 
       file.name = obj.file_name; 
       if (obj.error == true) { 
        file.previewElement.classList.add("dz-error"); 
       } else { 
        file.previewElement.classList.add("dz-success"); 
        $("#my-dropzone").append($('<input type="hidden" ' + 'name="product_images[]" ' + 'value="' + obj.file_name + '">')); 
       } 
      } 
     }; 

그러나 이것은 단지 일 당신이 다른 당신이 시간에 대해 여러 개의 이미지를 업로드하는 경우 루프를 시도해야 .. 이미지 하나 하나를 업로드하는 경우. 난 당신이 이해 바랍니다.