【问题标题】:Message: move_uploaded_file(): failed to open stream: Permission denied in codeigniter消息:move_uploaded_file():打开流失败:codeigniter 中的权限被拒绝
【发布时间】:2016-03-16 04:19:06
【问题描述】:

我的项目使用 xampp 在 localhost 中运行良好,但在远程服务器中,当我尝试上传或更新图像时出现错误,..

警告:
消息:move_uploaded_file(images/1458100947_2.jpg): 无法打开流:权限被拒绝

这是错误所在的代码。

            $imagename = $this->person->view($this->input->post('id'))->image;
     if(file_exists("images/$imagename")) unlink("images/".$imagename);
     $fileName = time(). '_' .$_FILES["image"]["name"];
        move_uploaded_file($_FILES["image"]["tmp_name"],$output_dir.$fileName); //this line
$targetPath = 'images/' . $fileName;
    $config_resize['image_library'] = 'gd2';
     $config_resize['create_thumb'] = FALSE;
     $config_resize['maintain_ratio'] = TRUE;
  //   $config_resize['master_dim'] = 'height';
     $config_resize['quality'] = "80%";
     $config_resize['source_image'] = $targetPath;
     $config_resize['height'] = 600;
     $config_resize['width'] = 1024;
  //   $config_resize['thumb_marker'] = '';
     $config_resize['new_image'] = 'images/' . $fileName;
     $this->image_lib->initialize($config_resize);
     $this->image_lib->resize();

     $uploaded = TRUE;

我正在尝试 google 如何在 codeigniter 中将权限设置为 777,但没有运气。这是我的项目链接 http://mysports.orgfree.com。使用此管理员帐户。

用户名:mak 密码:mak

登录并单击编辑按钮,然后上传一些图像.. 之后将显示错误.. 谢谢...

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    您好,您可以授予 2 路权限

    1) 直接用这种方式给文件夹权限

    chmod("folder name with path", 755); 
    

    2)直接用这种方式给文件权限,并在move_uploaded_file函数后使用这段代码

    chmod("file name with path", 644); 
    

    【讨论】:

      【解决方案2】:

      我能够通过使用 SmartFTP 上传文件来解决我的权限问题,因为它提供了一种设置权限的简单方法。这解决了我的问题,我的代码现在可以工作了。

      【讨论】:

        猜你喜欢
        • 2019-07-25
        • 2018-08-21
        • 2015-11-02
        • 2023-03-18
        • 2017-09-17
        • 2013-06-19
        • 2016-08-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多