PHP 上传文件为什么会失败?

来源:百度知道 编辑:UC知道 时间:2024/06/07 18:42:55
--------html文件(upload.html)
<html><head><title>上载文件表单</title></head>

<body>

<form enctype="multipart/form-data" action="upload.php" method="post">

<input type="hidden" name="max_file_size" value="100000">

<center>请选择文件:

<input name="userfile" type="file">

<input type="submit" value="上传文件">

</center>

</form>

</body>

----------接收文件(upload.php)
<html>

<head>

<title>处理上载文件</title>

</head>

<body>

<?

copy($userfile,"newfile");
echo $userfile."-文件上传的路径";

echo $userfile_name."-在用户机器上该文件的原始名称 ";

echo $userfile_size.&

<form name="form1" enctype="multipart/form-data" action="upload.php" method="post">
<p></p>
上传到files文件夹中:
<input name="upload_file" id="upload_file" type="file" style="border-color:#99CCCC; background-color:#E0EEEE;">
<input type="submit" value="上传文件" name="submit">
</form>

e盘要有个files文件
upload.php
<?
$upload_file=$_FILES['upload_file']['tmp_name'];
$upload_file_name=$_FILES['upload_file']['name'];

if($upload_file){
$file_size_max = 2000*1000;// 2M限制文件上传最大容量(bytes)
$store_dir = "E:/files";// 上传文件的储存位置
$accept_overwrite = 1;//是否允许覆盖相同文件
// 检查文件大小
if ($upload_file_size > $file_size_max) {
echo "对不起,您的文件容量大于规定";
exit;
}

// 检查读写文件
if (file_exists($store_dir .