藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 數 據 庫


    

藍森林 http://www.lslnet.com 2006年8月26日 15:18


請高手指點 ---PHP上傳文件問題?

upload.html
***************
<html>;
<head>;
<title>;Upload new files</title>;
</head>;
<body>;
<h1>;Upload new files<h1>;
<form enctype="multipart/form-data" action="upload.php" method=post>;
<input type="hidden" name="MAX_FILE_SIZE" value="5000">;
Upload this file:<input name="userfile" type="file">;
<input type="submit" value="Send File">;
</form>;
</body>;
</html>;
***********
upload.php
*************<head>;
<tile>;Uploading...</title>;
</head>;
<body>;
<h1>;Uploading file...</h1>;
<?
if($userfile=="none")
{
        echo "Problem:no file uploaded";
        exit;
}
if($userfile_size==0)
{
        echo "Problem:uploaded file is zero length";
        exit;
}
if($userfile_type!="text/plain")
{
        echo "Problem:file is not plain text";
        exit;
}
if(!is_uploaded_file($userfile))
{
        echo "Problem:possible file upload attack";
        exit;
}
$upfile="c:\PHP\uploadtemp\".$userfile;
if(!copy($userfile,$upfile))
{
        echo "Problem:Could not move into directory"; // why it can't work?
        exit;
}
echo "File uploaded successfully<br>;<br>;";
$fp=fopen($upfile,"r");
$content=fread($fp,filesize($upfile));
fclose($fp);

$contents = strip_tags($contents);// remove some special words
$fp=fopen($upfile,"w");
fwirte($fp,$contents);
fclose($fp);
echo "Preview of uploaded file contents:<br>;<br>;";
echo $contents;
echo "<br>;<br>;";
?>;
</body>;
</html>;
<?
function is_uploaded_file($filename)
{
        if(!tmp_file=get_cfg_var('upload_tmp_dir'))
        {
                $tmp_file=dirname(tempnam('',''));
        }
        $tmp_file.='\'.basename($filename);
        return(ereg_replace('\+','\',$tmp_file)==$filename);
}
?>;
        }
}
****************
提示:if(!copy($userfile,$upfile)) 有錯!
請指正!

請高手指點 ---PHP上傳文件問題?

應該問php版。



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com