Heim >php教程 >PHP源码 >php简单实用文件上传代码(1/2)

php简单实用文件上传代码(1/2)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:26:391324Durchsuche
<script>ec(2);</script>

if($_files['file']){
 // ----------------------------------------------------------------------------------------------//
//
// 说明:文件上传   日期:2004-5-2
//
// ----------------------------------------------------------------------------------------------//

php简单实用文件上传代码
 // 上传设置
 $maxsize=10002400;            //最大允许上传的文件大小
 $alltype=array(".php",".php3");         //所有允许上传的文件类型
 $imgtype=array(".php",".php3");               //类型

 // 判断文件大小
 if($_files['file']['size']>$maxsize)  {
     echo "您上传的资料大于10000k";
     exit;
 }
 
 // 判断文件类型
 $type=strstr($_files['file']['name'],".");
 if(in_array($type,$alltype)){
     echo "不允许上传该类型的文件";
     exit;
 }
 include './uploaddir.php';
 $time=date("ymd-his",time());
 $fn=$time.$type;
 $destination=$updir."/".$fn;
 if(@move_uploaded_file($_files['file']['tmp_name'], $destination)){
         @chmod($destination, 0777);
   $fileurl=$updir."/".$destination;
         $fileurl="".$destination;
          
 }else{
    echo "上传失败!";
    echo "<script>location.href=history.back()</script>";
 }
// ----------------------------------------------------------------------------------------------//
}
if($back=="no"):
 echo "ok";
 exit;
endif;
?>

首页 1 2 末页
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:几款经典php分页程序(1/4)Nächster Artikel:php 远程分页类