unfile.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>文件上传页面</TITLE>
</HEAD>
<BODY>
<FORM ACTION="upload.php" ENCTYPE="multipart/form-data" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="FILE" Name ="uploadfile" SIZE="24" MAXLENGTH="80">
<BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Upload File!" NAME="sendit">
<INPUT TYPE="SUBMIT" VALUE="Cancel" NAME="cancelit"><BR>
</FORM>
</BODY>
</HTML>
-——————————————————————————————————————————————————————————————————————————————
upload.php:
<?php$uploaddir = "/usr/local/apache2/htdocs/xsgl/wenjian/";//去掉uploads
$uploadfile = $uploaddir.$_FILES["uploadfile"]["name"];//upfile->uploadfile
if ($_FILES["uploadfile"]["error"] > 0)
{
echo "Error: " . $_FILES["uploadfile"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["uploadfile"]["name"] . "<br />";
echo "Type: " . $_FILES["uploadfile"]["type"] . "<br />";
echo "Size: " . ($_FILES["uploadfile"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["uploadfile"]["tmp_name"];
}
if(move_uploaded_file($_FILES["uploadfile"]["tmp_name"], $uploadfile))//upfile->uploadfile
{
print "SUCCESS! \n";
print_r($_FILES);
}
else
{
print "FAIL!\n";
print_r($_FILES);
}
?>