日期:2014-05-16 浏览次数:20500 次
<form action = "upload_file.php" method = "post" enctype = "multipart/form-data">
<label for = "file">Filename</label>
<input type = "file" name = "file" id = "file"/>
<br>
<input type = "submit" name = "submit" value = "上传"/>
</form>
<?php
if($_FILES["file"]["error"] > 0)
{
echo "Error : ".$_FILES["file"]["error"]."<br>";
}
else
{
echo "Upload: ".$_FILES["file"]["name"]."<br>";
echo "Type: ". $_FILES["file"]["type"]."<br>";
echo "Size: ".($_FILES["file"]["size"]/1024)."KB<br>";
echo "Stored in: ".$_FILES["file"]["tmp_name"]."<br>";
if(file_exists("upload/".$_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"]." already exists.";
}
else
{
//move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$_FILES["file"]["name"]);// 报错
move_uploaded_file("upload/".$_FILES["file"]["name"],$_FILES["file"]["tmp_name"]);
echo "<br><br><br> Storeed in: "."upload/".$_FILES["file"]["name"];
}
}
?>