我可以在完成上传文件后知道如何重置表单或刷新页面而没有任何问题吗?我需要提到的是html文件将存储在根目录和php文件存储在root / php / upload_action.php
这是我的HTML代码:
<form enctype="multipart/form-data" action="./php/upload_action.php" method="POST">
Model to upload: <input type="file" name="userfile" required="required"
<input type="reset" value="reset">><input type="submit" value="submit">
</form>
这将是我的PHP代码:
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo '<script language="javascript">';
echo 'alert("Done!")';
echo '</script>';
} else {
echo '<script language="javascript">';
echo 'alert("Failed! Try again later...")';
echo '</script>';
}
答案 0 :(得分:1)
ob_start();
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo '<script language="javascript">';
echo 'alert("Done!")';
echo '</script>';
header( "refresh:0; url=pagename.php" );
}