标准表单就足以上传,只需记住在表单中包含mime即可。然后你可以使用$ _FILES ['']来引用该文件。
然后你可以检查提供的文件名并查看它是否存在于文件系统中使用file_exists()检查文件名或者如果你不需要保留旧文件,你可以使用perofrm文件移动并覆盖旧文件一个与临时目录中的新
// this assumes that the upload form calls the form file field "myupload"
$name = $_FILES['myupload']['name'];
$type = $_FILES['myupload']['type'];
$size = $_FILES['myupload']['size'];
$tmp = $_FILES['myupload']['tmp_name'];
$error = $_FILES['myupload']['error'];
$savepath = '/yourserverpath/';
$filelocation = $svaepath.$name;
// This won't upload if there was an error or if the file exists, hence the check
if (!file_exists($filelocation) && $error == 0) {
// echo "The file $filename exists";
// This will overwrite even if the file exists
move_uploaded_file($tmp, $filelocation);
}
// OR just leave out the "file_exists()" and check for the error,
// an if statement either way
?>