代码如下 | 复制代码 |
<html> <head> <title>文件上传</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"> <? require './global.php'; $updir="uploaddir"; $form?$form=$form:$form="form1"; if(!$inputname)$inputname=$_GET['inputname']; if($uploadfile){ $copyfilename=date('YmdHis',time()); if(!is_dir($updir))mkdir($updir,777); $filetype=array(".php",".php3"); $type=substr($uploadfile['name'],strrpos($uploadfile['name'],'.'),strlen($uploadfile['name'])-strrpos($uploadfile['name'],'.')); if(in_array($type,$filetype)){echo "上传的文件不符合格式<a href="javascript教程:history.go(-1)"> 点击返回</a>";exit;} $dir="$updir/$copyfilename.$type"; if(function_exists("ImageJpeg")&&eregi("(.jpg)$",$uploadfile_name)&&$w) include("gd.php"); if(move_uploaded_file($uploadfile,$dir)){ chmod($dir, 0777); $ckupload=2; } if(!$ckupload){ if(move_uploaded_file($uploadfile['tmp_name'],$dir)){ chmod($dir, 0777); $ckupload=2; } } if(!$ckupload){ echo "<CENTER>文件上传不成功,请再次上传,如果多次不成功,请联系管理员<a href="javascript:history.go(-1)"> 点击返回</a></CENTER>"; exit; } else { echo "上传成功1,<A HREF=?>继续上传</A>"; echo"<script>parent.$form.$inputname.value='$updir/$copyfilename$type'</script>"; exit; } } ?> <form name="form1" method="post" action="" enctype="multipart/form-data"> <input class=mmcinb type="file" name="uploadfile" style="height:20px; background-color:#f3f3f3; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" > <input class=mmcinb type="submit" name="Submit" value="上传文件" style="height:20px; background-color:#f3f3f3; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#FFC864'" onMouseOut ="this.style.backgroundColor='#f3f3f3'" > </form> </body> |
时间: 2024-10-05 19:17:48