Transfer file to confirmation screen

index.php

<form action="confirm.php" enctype="multipart/form-data" method="post">
...

<p>
								職務経歴書<br>
								<label><input id="select-file" style="display:none" type="file" name="filename" onChange="file_selected()"><input id="file-name" type="text" value="ファイルを選択してください" readonly="readonly" onclick="file_select()"></label><span id="message">選択されていません</span>
							</p>
...
<p>
								「<a href="privacy.php">個人情報の取り扱い</a>」に同意の上、無料登録するのボタンをクリックしてください。
								<input type="submit" id="regist" value="同意して無料登録する">
							</p>
						</form>

confirm.php

 $upload = './cfile/'.$_FILES['filename']['name'];
 if(move_uploaded_file($_FILES['filename']['tmp_name'],$upload)){
 	echo 'success';
 } else {
 	echo 'failed';
 }

successed

delete temporary file before upload.

 $dir = glob('./cfile/*');
 foreach($dir as $file){
 	unlink($file);
 }
 $upload = './cfile/'.$_FILES['filename']['name'];
 if(move_uploaded_file($_FILES['filename']['tmp_name'],$upload)){
 	echo 'success';
 } else {
 	echo 'failed';
 }

– If this is done, the uploaded file will disappear when multiple users operate, so it has to be deleted by cron batch etc.

 $upload = './cfile/'.date("YmdHis").$_FILES['filename']['name'];
 if(move_uploaded_file($_FILES['filename']['tmp_name'],$upload)){
 	echo 'success';
 } else {
 	echo 'failed';
 }