2016-12-21 3 views
-1

私は、ファイルが投稿されていない理由を理解できないようなフォームがあります。フォーム提出でファイルが投稿されない

これはかなりまっすぐ進むはずですが、私のお尻を蹴るようです。

私はPHPmailerプラグインを使用しています。

私は他のフィールドをすべて取得していますが、電子メールは届きますが、ファイルは決して投稿されません。

フォームコード。私は、ファイルを探し、それが偽と評価さ

<form id="bookrelease" name="bookrelease" method="post" enctype="multipart/form-data"> 
 
    <div class="row"> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="startdate"> 
 
     <div class='input-group date' id='datetimepicker1'> 
 
      <input id="startdate" name="startdate" type='text' class='inputspecial form-fixed-height' placeholder="&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Start Date"> 
 
      <span class="input-group-addon calendarbtn"> 
 
                <span class="glyphicon glyphicon-calendar calendarbtn2"></span> 
 
      </span> 
 
     </div> 
 
     <label for="startdate" id="startdateLb"><span class="error">*Start date required.</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="enddate"> 
 
     <div class='input-group date' id='datetimepicker2'> 
 
      <input id="enddate" name="enddate" type='text' class='inputspecial form-fixed-height' placeholder="&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End Date"> 
 
      <span class="input-group-addon calendarbtn"> 
 
                <span class="glyphicon glyphicon-calendar calendarbtn2"></span> 
 
      </span> 
 
     </div> 
 
     <label for="enddate" id="enddateLb"><span class="error">*End date required.</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="BRauthorname"> 
 
     <input class="form-fixed-height" type="text" id="BRauthorname" name="BRauthorname" placeholder="Author Name"> 
 
     <label for="BRauthorname" id="BRauthornameLb"><span class="error">*Author name required</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="ABRemail"> 
 
     <input class="form-fixed-height" type="email" id="ABRemail" name="ABRemail" placeholder="Author Email"> 
 
     <label for="ABRemail" id="ABRemail-1Lb"><span class="error error1">*Email Field Required</span> 
 
     </label> 
 
     <label for="ABRemail" id="ABRemail-2Lb"><span class="error error2">*Email Not Valid</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="booktitle"> 
 
     <input class="form-fixed-height" type="text" id="booktitle" name="booktitle" placeholder="Book Title"> 
 
     <label for="booktitle" id="booktitleLb"><span class="error">*Book title required</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="authorwebsite"> 
 
     <input class="form-fixed-height optional" type="url" id="authorwebsite" name="authorwebsite" placeholder="Author Web Site - optional"> 
 
     </p> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="sellerssite"> 
 
     <input class="form-fixed-height" type="url" id="sellerssite" name="sellerssite" placeholder="Book Retailer's Web Address"> 
 
     <label for="sellerssite" id="sellerssiteLb"><span class="error">*Book retailer's web address required</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class='booktype'> 
 
     <input class="form-fixed-height optional" type="text" id="booktype" name="booktype" placeholder="Format(s) - optional"> 
 
     </p> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="genre"> 
 
     <input class="form-fixed-height optional" type="text" id="genre" name="genre" placeholder="Genre(s) - optional"> 
 
     </p> 
 
    </div> 
 
    <div class="col-xs-12 col-sm-12 col-m-6 col-lg-6"> 
 
     <p class="fixedheight"> 
 
     <input class="file form-fixed-height" id="BRfile" type="file" name="BRfile" data-preview-file-type="image" /> 
 
     <label for="BRfile" id="BRfileLb"><span class="error">*opps! invalid file. Only jpeg and png files accepted</span> 
 
     </label> 
 
     </p> 
 
    </div> 
 
    </div> 
 
    <div class="text-center"> 
 
    <div id="ErrResults"> 
 
     <!-- Error Here --> 
 
    </div> 
 
    <div id="MainResult"> 
 
     <!-- Response Here --> 
 
    </div> 
 
    <a href="#" class="contact-btn bookrelease-btn">Send Message</a> 
 
    <input type="submit" value="BRfile" class="contact-btn bookrelease-btn"> 
 
    </div> 
 
</form>

PHPコード。

if (array_key_exists($_POST['postBRfile'], $_FILES)) { 
 
      // First handle the upload 
 
      // Don't trust provided filename - same goes for MIME types 
 
      // See http://php.net/manual/en/features.file-upload.php#114004 for more thorough upload validation 
 
      $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES[$_POST['postBRfile']]['name'])); 
 
      if (move_uploaded_file($_FILES[$_POST['postBRfile']]['tmp_name'], $uploadfile)) { 
 
       $mail->addAttachment($uploadfile, 'My uploaded file'); 
 
      } 
 
    
 
    }

+0

'$ _POST ['postBRfile']'とは何ですか? – Dekel

+0

入力ファイルの名前は 'BRfile'なので、' $ _FILES ['BRfile'] 'を使うべきです。あなたが '$ _POST ['postBRfile']'の中に何があるのか​​分かりませんが、 'BRfile'でなければあなたのコードは動作しません。 – Dekel

答えて

0

私はpostBRfile

これを試してみてくださいを理解していません。

if (array_key_exists($_POST['BRfile'], $_FILES)) { 
     // First handle the upload 
     // Don't trust provided filename - same goes for MIME types 
     // See http://php.net/manual/en/features.file-upload.php#114004 for more thorough upload validation 
     $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES[$_POST['BRfile']]['name'])); 
     if (move_uploaded_file($_FILES[$_POST['BRfile']]['tmp_name'], $uploadfile)) { 
      $mail->addAttachment($uploadfile, 'My uploaded file'); 
     } 

} 
+0

だから私は、クライアント側の検証を行っているjqueryファイルがあったことを忘れていました。それは問題がどこにあるのかもしれません。私は検証するコードを掘り下げようとしています。 – tylerbarton

+0

問題は –

+0

まで入れてもらえません。ファイルをアップロードすることができません。今は、プロジェクトを支えていたコードをコメントアウトしました。アップグレードの後に​​再訪することになります。 。 – tylerbarton

関連する問題