免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1214 | 回复: 1
打印 上一主题 下一主题

请高手指点 ---PHP上传文件问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-03 20:36 |只看该作者 |倒序浏览
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 "roblem:no file uploaded";
exit;
}
if($userfile_size==0)
{
echo "roblem:uploaded file is zero length";
exit;
}
if($userfile_type!="text/plain"
{
echo "roblem:file is not plain text";
exit;
}
if(!is_uploaded_file($userfile))
{
echo "roblem:possible file upload attack";
exit;
}
$upfile="c:\PHP\uploadtemp\".$userfile;
if(!copy($userfile,$upfile))
{
echo "roblem: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 "review 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)) 有错!
请指正!

论坛徽章:
0
2 [报告]
发表于 2003-06-03 21:25 |只看该作者

请高手指点 ---PHP上传文件问题?

原帖由 "sweetsoup" 发表:
upload.html
***************
<html>;
<head>;
<title>;Upload new files</title>;
</head>;
<body>;
<h1>;Upload new files<h1>;
<form enctype="mult..........
   
$upfile="c:\PHP\uploadtemp\".$userfile;
把$upfile打出来看看对不对
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP