前提・実現したいこと
wordpress テーマsneaker
プラグイン:コンタクトフォーム7
お客様予約登録ページから確認ページに画像データを渡して、メール送信がしたい。
1 お客入力ページ input type="file" 画像をアップ → 確認画面に進む。
2 確認ページ コンタクトフォームの[file readonly]にファイル名もしくわアップした画像を記載 → 予約完了
確認、及びメール送信は、コンタクトフォームを使用希望。
長々コードを書いてしまいますが、内容の把握のため記載しました。
何卒ご教授お願いできればと思います。
発生している問題
予約ページ 3ページ目の、input file画像データを4ページ目の確認ページで画像データ受け取れず、メール送信できない。
該当のソースコード
---functions.php---
php
1function form_post() { 2 if(isset($_POST)){ 3 $postArray = json_encode($_POST, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); 4 echo '<script>var postArray = '. $postArray .';</script>'; 5 } 6} 7add_shortcode('form', 'form_post');
● 1ページ目 page-place.php
php
1<form name="myform1" action="/day" method="post" id="formplace"> 2<div class="formplace"> 3<select type="select" name="place" id="alert1"> 4 <option value="店舗場所を選択してください">計測場所を選択してください</option> 5 <option value="tenpo1">tenpo1</option> 6 <option value="tenpo2">tenpo2</option> 7 <option value="tenpo3">tenpo3</option> 8 </select> 9</div> 10<button type="submit" id="submit_btn1">日程を決める</button> 11</form>
●2ページ目 page-day.php
php
1<form name="myform2 "action="/adress" method="post" class="formday"> 2 3<div class="formday"> 4<label>日時を選択</label> 5<input type="date" name="date" id="alert2" > 6<select name="time" id="alert3"> 7 <option value="時間を選択してください">時間を選択してください</option> 8 <option value="10:00~11:00">10:00~11:00</option> 9</select> 10</div> 11 <?php 12 $place = htmlspecialchars($_POST['place']); 13 ?> 14 <input type="hidden" name="reserve1" value="<?php echo $place ?>"> 15 16<button type="submit" id="submit_btn2">ご連絡先を登録する</button> 17 18</form>
●3ページ目 page-adress.php
php
1<form name="myform3 "action="/result" method="post" class="formadress" enctype="multipart/form-date"> 2 3<div class="formadress" > 4<input type="text" name="fam" id="alert4"> 5<input type="text" name="given" id="alert5"> 6<input type="tell" name="tell" id="alert6"> 7<input type="email" name="your-email" id="alert7"> 8 9※※<input type="file" accept="image/*;capture=camera" name="files" id="alert8">※※ 10 11</div> 12 13 <?php 14 $reserve1 = htmlspecialchars($_POST['reserve1']); 15 $date = htmlspecialchars($_POST['date']); 16 $time = htmlspecialchars($_POST['time']); 17 ?> 18 <input type="hidden" name="reserve12" value="<?php echo $reserve1 ?>"> 19 <input type="hidden" name="reserve2" value="<?php echo $date ?>"> 20 <input type="hidden" name="reserve3" value="<?php echo $time ?>"> 21 22<button type="submit" id="submit_btn3">登録確認</button> 23</form>
●4ページ目 page-result.php
php
1<?php echo do_shortcode('[form]'); ?> 2 <script> 3 jQuery(function($) { 4 //配列から値を取得 5 var reserve12 = postArray['reserve12']; 6 var reserve2 = postArray['reserve2']; 7 var reserve3 = postArray['reserve3']; 8 var fam = postArray['fam']; 9 var given = postArray['given']; 10 var tell = postArray['tell']; 11 var youremail = postArray['your-email']; 12 ※※var files = postArray['files'];※※ 13 //値をフォームに入力 14 $('input[name="reserve12"]').val(reserve12); 15 $('input[name="reserve2"]').val(reserve2); 16 $('input[name="reserve3"]').val(reserve3); 17 $('input[name="fam"]').val(fam); 18 $('input[name="given"]').val(given); 19 $('input[name="tell"]').val(tell); 20 $('input[name="your-email"]').val(youremail); 21 ※※$('input[name="files"]').val(files);※※ 22 }); 23 </script>
コンタクトフォーム7
html
1<label>ご計測場所</label> 2[text* reserve12 readonly] 3<label>ご日程</label> 4[text* reserve2 readonly] 5<label>お時間</label> 6[text* reserve3 readonly] 7<label>お名前 氏</label> 8[text* fam readonly] 9<label>お名前 名</label> 10[text* given readonly] 11<label>お電話番号</label> 12[text* tell readonly] 13<label>メールアドレス</label> 14[email* your-email readonly] 15<label>イメージ写真</label> 16[file* files limit:5mb filetypes:png|jpeg readonly] 17 18[submit "送信"] 19
試したこと
4ページ目の
var files = postArray['files'];
$('input[name="files"]').val(files);
の記述が違っていりのではないかと推測しています。
補足情報(FW/ツールのバージョンなど)
wordpress 5.3.2
contactform7 最新
ここにより詳細な情報を記載してください。
あなたの回答
tips
プレビュー