2
回答
uploadify在tp中使用为什么不能将文件名添加到数据库里呢?
极速云服务器,低至1.04元/天>>>   
//上传图片
       
        $now = date("Ymd_His");
        $code = $now."_".mt_rand(10000, 99999);
   
        if(!empty($_FILES)){
       
       
       
        //如果有文件上传 上传附件
        import("ORG.Net.UploadFile");
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize  = 2048000 ;
        //设置上传文件类型
        $upload -> allowExts  = array("jpg", "gif", "png","jpeg");
        //设置附件上传目录
        $upload->savePath =  "./Public/uploads/case/";
        //设置需要生成缩略图,仅对图像文件有效
        $upload->thumb =  true;
       
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        //设置需要生成缩略图的文件后缀
        $upload->thumbPrefix   =  'b_,s_';  //生产3张缩略图
       //设置缩略图最大宽度
        $upload->thumbMaxWidth =  '600,150';
       //设置缩略图最大高度
        $upload->thumbMaxHeight = '600,150';
        $upload->saveRule=$code;
     
       
        if(!$upload->upload()) {
          
            alert($upload->getErrorMsg());
        }else {
           
          $fileinfo = $upload->getUploadFileInfo();//得到已上传文件的信息数组
         
           
        }
       
       
        //$data['name'] = msubstr(substr($fileinfo[0]['name'], 0, strrpos($fileinfo[0]['name'], '.')),0,10,'utf-8',false);
        $case=M('case');
        $data['title']=$fileinfo[0]['savename'];
        $case->add($data);
   
     
      }else{
        echo "<p style='font-size:999px;'>没有获取值</p>";
       
      } 
举报
keyjian
发帖于5年前 2回/418阅
顶部