linux - Thinkphp文件上传错误提示:不存在的图像文件,本地测试不会这样的,放到服务器才会这样,为什么?

WBOY
Release: 2016-06-06 20:07:37
Original
1979 people have browsed it

错误的位置:ThinkPHP/Library/Think/Image/Driver/Gd.class.php  LINE: 42

js部分:

<code>$(".upavater").change(function(){
  var fdpic=new FormData();
  var pic=$("#upavater").get(0).files[0];
  fdpic.append("pic",pic);
$.ajax({  
          url: avaterurl,  
          type: 'POST',  
          data: fdpic,  
          //async: false,  
          cache: false,  
          enctype: 'multipart/form-data',
          contentType: false, 
          processData: false
          success:function(d){colsole.log(d);}
      })
})</code>
Copy after login
Copy after login

控制器部分:

<code>public function avater(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小3M
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =     "./Public/avater/"; // 设置附件上传根目录
        $upload->subName  =     array('date','Ym');
        $info   =   $upload->upload();
        if($Info){echo "上传成功";}else{echo "上传失败";}
        }</code>
Copy after login
Copy after login

本地测试没有问题,但部署到linux服务器就出问题了。

回复内容:

错误的位置:ThinkPHP/Library/Think/Image/Driver/Gd.class.php  LINE: 42

js部分:

<code>$(".upavater").change(function(){
  var fdpic=new FormData();
  var pic=$("#upavater").get(0).files[0];
  fdpic.append("pic",pic);
$.ajax({  
          url: avaterurl,  
          type: 'POST',  
          data: fdpic,  
          //async: false,  
          cache: false,  
          enctype: 'multipart/form-data',
          contentType: false, 
          processData: false
          success:function(d){colsole.log(d);}
      })
})</code>
Copy after login
Copy after login

控制器部分:

<code>public function avater(){
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     3145728 ;// 设置附件上传大小3M
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->rootPath  =     "./Public/avater/"; // 设置附件上传根目录
        $upload->subName  =     array('date','Ym');
        $info   =   $upload->upload();
        if($Info){echo "上传成功";}else{echo "上传失败";}
        }</code>
Copy after login
Copy after login

本地测试没有问题,但部署到linux服务器就出问题了。

查看图片目录文件是否存在,权限是否有

怎么解决啊?也遇到了同样的问题,找半天也没找到原因??

这种情况多半是文件读写权限的问题!

给 Upload 文件夹权限

给 Upload 文件夹权限

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template