想请各位前辈帮忙 谢谢~
以下是我在练习时遇到的问题:
目的: 于上传页面按下上传的按钮后,转到下一页组XML并将档案上传到服务器上。
目前XML档案已可正常下载至本机,但无法直接上传到服务器上
请问是使用move_uploaded_file函式将档案上传吗?
有尝试过用浏览档案的方式进行上传,可正常上传
但是要试着改成按下上传的按钮后直接上传,就会一直失败
前台
<form method="post" enctype="multipart/form-data" action="export.php">
<input type="submit" value="upload">
</form>
后台
<?php
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['upload']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['upload']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\\\\n";
} else {
echo "Possible file upload attack!\\\\n";
}
?>