一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php文件上传代码

时间:2008-05-22 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码


 $uploadpath='../upload/';
 $uploadtype='image/x-pngimage/gifimage/pjpeg';
 $uploadsava='';
 $uploadpath.=md5(date('y:m:d h:i:s')); 
 $phototype=isset($_POST['select'])?$_POST['select']:"";
 $title=Strreplace(isset($_POST['title'])?$_POST['title']:"null");
 $say=Strreplace(isset($_POST['textarea'])?$_POST['textarea']:"null");
 $tdate=date("Y:m:d"); 
 $uploadtype=$_FILES['file']['type'];


 if ($phototype=='null' || $phototype==""){
 echo("");
 exit();
 }
 if($title=="null" || $title=="" || strlen($title)>50){
 $title="暂无标题";
 }
 if($say=="null" || $say=="" || strlen($say)>500){
 $say="暂无说明";
 } 
 if(strpos('exit:image/x-png',$uploadtype)){
  $uploadsava=$uploadpath.".png";
 }
 if(strpos('exit:image/gif',$uploadtype)){
  $uploadsava=$uploadpath.".gif";
 }
 if(strpos('exit:image/pjpeg',$uploadtype)){
  $uploadsava=$uploadpath.".jpg";
 } 
 if($uploadsava==''){
 echo("");
 exit();
 }
 if($_FILES['file']['size']>202400){
 echo("");
 exit();
 }
 

if(move_uploaded_file($_FILES['file']['tmp_name'],$uploadsava)){
 echo("");
 $sql="insert into photo(name,picpath,picdate,pichit,picsay,filesendid,phototype) values('$title','$uploadsava','$tdate',1,'$say','$xm','$phototype')";
 mysql_query($sql) or die('Insert Data Fail Errors'.mysql_error()); 
}else{
 echo("");
}   www.111com.net

?>

原创文章 载注明:  www.111com.net

热门栏目