我正在将表单提交到预览页面(表单),然后最终提交。我无法让 move_uploaded_file 工作。我该如何解决这个问题?当我检查目录时,那里没有文件。
预览页面
$tmpname = $_FILES['titleimage']['tmp_name'];
$imagefile = $_FILES['titleimage']['name'];
$filename = basename($imagefile);
$imagename = dirname(__FILE__).'/avatar/'.$filename;
echo "<form enctype='multipart/form-data' id='submitpreview' action='/upload' method='POST'>
<input type='hidden' name='image' value='$tmpname' readonly />
<input type='hidden' name='imagedir' value='$imagename' readonly />";
//other code
echo "<div id='preview-submit-button'><a>Submit</a></div>
</form>";
上传页面
$image = $_POST['image'];
$directory = $_POST['imagedir'];
move_uploaded_file($image,$directory);