无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
<HTML>
<HEAD>
<TITLE>文件上传</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
<BODY>
<?
$UploadedFile=$_FILES['UploadedFile']['tmp_name'];
$UploadedFile_name=$_FILES['UploadedFile']['name'];
$isTrue=false;
if($UploadedFile)
{
$store_dir=$_SERVER['DOCUMENT_ROOT'];
$accept_overwrite = 1;
$isTrue=true;
}
$fileName = date("YmtHis").$UploadedFile_name;
if (file_exists($store_dir . $fileName))
{
echo "存在相同文件名的文件";
}
$mytype =array(".jpg",".gif",".png");
$filetype=substr($_FILES['UploadedFile']['name'],strrpos($_FILES['UploadedFile']['name'],"."));
$typecount=0;
if($isTrue)
{
for($i=0;$i<count($mytype);$i++)
{
if($filetype==$mytype[$i])
{
$typecount++;
}
}
if($typecount>0)
{
if($_FILES['UploadedFile']['size']<1048576)
{
$b=move_uploaded_file($UploadedFile,$store_dir.$fileName);
if($b)
{
echo "<HR>\n";
echo "原文件信息:<br/>";
echo "名称:".$_FILES['UploadedFile']['name']."<BR>\n";
echo "大小:".$_FILES['UploadedFile']['size']."<BR>\n";
echo "类型:".$_FILES['UploadedFile']['type']."<BR>\n";
echo "<HR>\n";
echo "存入数据库的名称为:".$fileName;
echo "<HR>\n";
}
}
else
{
echo "文件大小不准超过1兆.";
}
}
else
{
echo "不准上传次类型文件!";
}
}
?>
<FORM ENCTYPE="multipart/form-data" ACTION="<?php echo $PHP_SELF ?>" METHOD="post">
<INPUT NAME="UploadedFile" TYPE="file" size='15'>
<INPUT TYPE="submit" VALUE="上传文件">
</FORM>
</BODY>
</HTML>
标签:
PHP,文件上传

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com