|
[php]
<html>
<head>
<title>文件上传</title>
</head>
<body>
<table>
<form ENCTYPE="multipart/form-data" name="myform" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<tr><td>选择上传文件</td><td><input name="myfile" type="file"></td></tr>
<tr><td><input name="submit" value="上传" type="submit"></td></tr>
</form>
</table>
<?php
echo "傲雪寒梅";
?>
</body>
</html>
[/php]
<?php
$upload_file = $_FILES['upload_file']['tmp_name'];
$upload_file_name = $_FILES['upload_file']['name'];
if($upload_file)
{
$file_size_max = 1000*1000;
$store_dir = "d:/";
$accept_overwrite = 1;
if($upload_file_size>$file_size_max)
{
echo "对不起,你的文件容量超过大于规定";
exit;
}
if(file_exists($store_dir.$upload_file_name)&& !$accept_overwrite)
{
echo "存在相同的文件名的文件";
exit;
}
if(!move_upload_file($upload_file,$store_dir.$upload_file_name))
{
echo "复制文件失败.";
exit;
}
echo "<p>你上传了文件;";
echo $_FILES['upload_file']['name'];
echo "<br>";
echo "文件的MIME类型为:";
echo $_FILES['upload_file']['type'];
echo "<br>";
echo "上传文件大小";
echo $_FILES['upload_file']['size'];
echo "<br>";
echo "文件上传临时存储为:";
echo $_FILES['upload']['tmp_name'];
echo "<br>";
$Erroe = $_FILES['upload_file']['error'];
switch($Erroe)
{
case 0:
echo "上传成功";
break;
case 1:
echo "上传超时最大限制值";
break;
case 2:
echo "一样超过最大限制值";
break;
case 3:
echo "文件只有部分被上传";
break;
case 4:
echo "没有文件被上传";
break;
}
}
?>
[php]
<?php
$upload_file = $_FILES['upload_file']['tmp_name'];
$upload_file_name = $_FILES['upload_file']['name'];
if($upload_file)
{
$file_size_max = 1000*1000;
$store_dir = "d:/";
$accept_overwrite = 1;
if($upload_file_size>$file_size_max)
{
echo "对不起,你的文件容量超过大于规定";
exit;
}
if(file_exists($store_dir.$upload_file_name)&& !$accept_overwrite)
{
echo "存在相同的文件名的文件";
exit;
}
if(!move_upload_file($upload_file,$store_dir.$upload_file_name))
{
echo "复制文件失败.";
exit;
}
echo "<p>你上传了文件;";
echo $_FILES['upload_file']['name'];
echo "<br>";
echo "文件的MIME类型为:";
echo $_FILES['upload_file']['type'];
echo "<br>";
echo "上传文件大小";
echo $_FILES['upload_file']['size'];
echo "<br>";
echo "文件上传临时存储为:";
echo $_FILES['upload']['tmp_name'];
echo "<br>";
$Erroe = $_FILES['upload_file']['error'];
switch($Erroe)
{
case 0:
echo "上传成功";
break;
case 1:
echo "上传超时最大限制值";
break;
case 2:
echo "一样超过最大限制值";
break;
case 3:
echo "文件只有部分被上传";
break;
case 4:
echo "没有文件被上传";
break;
}
}
?>
[/php]
我怎么不能上传 |
|