2016-06-13 8 views
0

ファイルアップローダー(HTML/CSS/Jquery)を持っていてuploader_1と呼び出せます。もう1つは(HTML、PHP)uploader_2となります。フォームの最後にアップロードするファイルをすべてuploader_1で作成しようとしています。何らかの理由で、私の検証PHPファイルでコードとすべてを適合させた後、私はuploader_2からのすべての情報で$_FILESを得ることができますが、uploader_1の何も表示されず、$_FILESでも$_POSTでもありません。ファイルアップローダーからファイル情報を取得できません

UPLOADER_1

HTML

<section class="col col-sm-5 rui" id="mupload5"> 
    <label class="label" for="file5"> 
     <b>Example</b> 
     <p>Description</p> 
    </label> 
    <div class="file-uploader__message-area"> 
     <p>Select a file</p> 
    </div> 
    <div class="file-chooser"> 
     <input type="file" class="file-chooser__input" id="file5"> 
    </div> 
    <?php 
    listPdf($id, 5); 
    ?> 
</section> 

のjQuery

//jQuery plugin 
(function($) { 

    $.fn.uploader = function(options) { 
    var settings = $.extend({ 
     MessageAreaText: "There is no file selected.", 
     MessageAreaTextWithFiles: "File list:", 
     DefaultErrorMessage: "Failed opening file.", 
     BadTypeErrorMessage: "Invalid type of file.", 
     acceptedFileTypes: ['pdf', 'jpg', 'gif', 'jpeg', 'bmp', 'tif', 'tiff', 'png', 'xps', 'doc', 'docx', 
     'fax', 'wmp', 'ico', 'txt', 'cs', 'rtf', 'xls', 'xlsx'] 
    }, options); 

    var uploadId = 1; 
    //update the messaging 
     $('.file-uploader__message-area p').text(options.MessageAreaText || settings.MessageAreaText); 

    //create and add the file list and the hidden input list 
    var fileList = $('<ul class="file-list"></ul>'); 
    var hiddenInputs = $('<div class="hidden-inputs hidden"></div>'); 
    $('.file-uploader__message-area').after(fileList); 
    $('.file-list').after(hiddenInputs); 

    //when choosing a file, add the name to the list and copy the file input into the hidden inputs 
    $('.file-chooser__input').on('change', function(){ 
     var file = $('.file-chooser__input').val(); 
     var fileName = (file.match(/([^\\\/]+)$/)[0]); 

     //clear any error condition 
     $('.file-chooser').removeClass('error'); 
     $('.error-message').remove(); 

     //validate the file 
     var check = checkFile(fileName); 
     if(check === "valid") { 

     // move the 'real' one to hidden list 
     $('.hidden-inputs').append($('.file-chooser__input')); 

     //insert a clone after the hiddens (copy the event handlers too) 
     $('.file-chooser').append($('.file-chooser__input').clone({ withDataAndEvents: true})); 

     //add the name and a remove button to the file-list 
     $('.file-list').append('<li style="display: none;"><span class="file-list__name">' + fileName + '</span><button class="removal-button" data-uploadid="'+ uploadId +'"></button></li>'); 
     $('.file-list').find("li:last").show(800); 

     //removal button handler 
     $('.removal-button').on('click', function(e){ 
      e.preventDefault(); 

      //remove the corresponding hidden input 
      $('.hidden-inputs input[data-uploadid="'+ $(this).data('uploadid') +'"]').remove(); 

      //remove the name from file-list that corresponds to the button clicked 
      $(this).parent().hide("puff").delay(10).queue(function(){$(this).remove();}); 

      //if the list is now empty, change the text back 
      if($('.file-list li').length === 0) { 
      $('.file-uploader__message-area').text(options.MessageAreaText || settings.MessageAreaText); 
      } 
     }); 

     //so the event handler works on the new "real" one 
     $('.hidden-inputs .file-chooser__input').removeClass('file-chooser__input').attr('data-uploadId', uploadId); 

     //update the message area 
     $('.file-uploader__message-area').text(options.MessageAreaTextWithFiles || settings.MessageAreaTextWithFiles); 

     uploadId++; 

     } else { 
     //indicate that the file is not ok 
     $('.file-chooser').addClass("error"); 
     var errorText = options.DefaultErrorMessage || settings.DefaultErrorMessage; 

     if(check === "badFileName") { 
      errorText = options.BadTypeErrorMessage || settings.BadTypeErrorMessage; 
     } 

     $('.file-chooser__input').after('<p class="error-message">'+ errorText +'</p>'); 
     } 
    }); 

    var checkFile = function(fileName) { 
     var accepted   = "invalid", 
      acceptedFileTypes = this.acceptedFileTypes || settings.acceptedFileTypes, 
      regex; 

     for (var i = 0; i < acceptedFileTypes.length; i++) { 
     regex = new RegExp("\\." + acceptedFileTypes[i] + "$", "i"); 

     if (regex.test(fileName)) { 
      accepted = "valid"; 
      break; 
     } else { 
      accepted = "badFileName"; 
     } 
     } 

     return accepted; 
    }; 
    }; 
}(jQuery)); 

//init 

$(document).ready(function(){ 
    $('.fileUploader').uploader({ 
    MessageAreaText: "Select a file." 
    }); 
}); 

UPLOADER_2

HTML

<section class="col col-sm-5 rui"> 
    <label class="label" for="file6"><b>IPO e/ou Documentos Técnicos</b></label> 
     <div class="upload-control"> 
      <input type="file" class="input-sm " name="file6" id="file6" style="height: 34px;" <?= $d; ?> /> 
      <button type="button" class="btn btn-labeled btn-danger force-auto-width add" aria-label="Left Align" id="deleteipo" > 
      <span class="fa fa-trash" aria-hidden="true"></span> 
      </button> 
      <?php 
      listPdf($id, 6); 
      ?> 
</section> 

私は、ファイルの情報を取得したい場所を今私のURLを提出しているPHPで..ですprint_rであるいは私が入れたものは何でもecho

PHP

print_r($_FILES); 
       echo 'HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEERE'.$_FILES['file5']; 
       die(); 

       if ($_FILES['file2']['size'] == 0) 
       { 
         $errors[12] = "Insert file 2"; 
       }else{ 
      unset($errors[12]); 
       } 

       if ($_POST['waranty'] == 7 and $_FILES['file3']['size'] == 0) 
       { 
         $errors[13] = "Insert file 3"; 
       }else{ 
      unset($errors[13]); 
       } 

       if ($_FILES['file1']['size']['0'] == 0) 
       { 
         $errors[14] = "Insert file 1"; 
       }else{ 
      unset($errors[14]); 
       } 

Uploader_1、それは表示されません...どうしたの?私に何ができる?非常に多くの方法でそれを取得しようとされて...

Uploader_1 Template Codepen

ますprint_rはRETURNS:

Array ( 
    [file2] => Array ([name] => [type] => [tmp_name] => [error] => 4 [size] => 0) 
    [file3] => Array ([name] => [type] => [tmp_name] => [error] => 4 [size] => 0) 
[file1] => Array ([name] => Array ([0] =>) [type] => Array ([0] =>)[tmp_name] => Array ([0] =>) [error] => Array ([0] => 4) [size] => Array ([0] => 0)) 
[file4] => Array ([name] => Array ([0] =>) [type] => Array ([0] =>) [tmp_name] => Array ([0] =>) [error] => Array ([0] => 4) [size] => Array ([0] => 0)) 
[file6] => Array ([name] => 17.png [type] => image/png [tmp_name] => /tmp/phpHJGS6F [error] => 0 [size] => 7014)) HEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEERE 
+0

誰も私に手を差し伸べることはできますか? – Kinder

答えて

0

をだから私が更新を得ました。私は$_FILESにファイルを取得することができました。だから、私は今、新しいアップロード(アップロード1)を使用して、私がする必要があることを行うことができます。しかし、今私は新しい問題を抱えています。私は、ファイルをアップロードする必要がある6つのセクション、別のファイルがあります。私は1 100%働くことができますが、2つ目はすべてを破壊します。このコードペンでデモを見ることができます。

1アップロードセクションhttp://codepen.io/heavenkinder/pen/BzzPrX

2アップロードセクションhttp://codepen.io/heavenkinder/pen/XKKBBa

1つのファイル、すべてが動作を停止し、またはporly働く、どんなにをinsering後。私はなぜ、私は両方のファイル入力を分離しようとしていましたが、同じものを持っているとは考えていません。私はjavascriptを分離する必要がありますか? HTMLの入力に異なる名前をつけて、それぞれにjavascriptを付けますか?

関連する問題