简体   繁体   English

无法使用codeigniter在AWS [Ubuntu]上上传文件

[英]Unable to upload file on AWS [Ubuntu] using codeigniter

I have AWS instance with Ubuntu and PHP configured. 我有配置了Ubuntu和PHP的AWS实例。 Every things work perfect. 每件事都完美无缺。 Only file upload not working. 仅文件上传无效。 Application developed in PHP [codeigniter] 用PHP开发的应用程序[codeigniter]

$this->load->library('form_validation');
$config = [
            'upload_path'    =>  "./data/user-avatar",
            'allowed_types'  =>  'gif|jpg|png|jpeg|JPEG',
            'encrypt_name'   =>   TRUE
         ];

        $this->load->library('upload',$config);

 if($this->upload->do_upload())
 {
    $data = $this->upload->data();
    echo $image = $data['file_name'];
 } else {
   echo "I am here in else";
 }

It executive else block directly. 它执行直接阻止。 Application work fine on local. 应用程序在本地工作正常。

  1. Checked upload dir permission its 777 检查了上载目录的权限其777
  2. Check on phpinfo file upload is on 检查phpinfo文件是否已上传

Any help to find of the error will be appreciated. 任何帮助找到该错误将不胜感激。

Thanks Prashant 感谢Prashant

Did you make sure your max upload size and max post are big enough on php.ini or your main php config file? 您是否确定php.ini或主php配置文件上的最大上传大小最大帖子足够大? it could not accept files bigger than X; 它不能接受大于X的文件;

Also you could get the $data['error'] to see if you get any code > 0 and find a answer from this; 您也可以获取$data['error']来查看代码是否大于0并从中找到答案。 maybe $error = $this->upload->display_errors(); 也许$error = $this->upload->display_errors(); could tell you more 能告诉你更多

Also check if your directory exists, using is_dir() to make sure you are not pointing to a different relative path (worth the check). 还要使用is_dir()检查目录是否存在,以确保您未指向其他相对路径(值得检查)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM