简体   繁体   English

file_put_content()文件权限错误

[英]file_put_content() file permission error

On my code I am sending url encoded image and using file_out_content to turn it to a file. 在我的代码上,我正在发送url编码的图像,并使用file_out_content将其转换为文件。

    if(file_put_contents($arg['org_file'],$decodeData))
    {
        chmod($arg['org_file'],777);
        $arg = Model_Photo::_convert_png_to_jpg($arg);

        //reduce file
        \Fuel\Core\Image::load($arg['org_file'])
                ->config('quality',80)
                ->resize($arg['width'])
                ->save($arg['org_file'],755);

When my execution gets the code above. 当我的执行获得上面的代码时。 the part with the Image::Load I get this error. 带有Image :: Load的部分,出现此错误。

Fuel\Core\PhpErrorException [ Warning ]:
getimagesize(/www/my.website.com/public/uploads/2013-11-18/4511582301f8b92b08aad0b8e.jpg): failed to open stream: Permission denied

You can see that I chmod the created file to 777, but looking at the console the permission is not 777. 您可以看到我将创建的文件更改为777,但是在控制台上,权限不是777。

--wxrw--wt 1 apache apache 291301 Nov 18 18:07 4511582301f8b92b08aad0b8e.jpg

The absence of read make it problematic for me to do file manipulation. 缺少读取使我无法进行文件操作。 I did the chmod but it is not working, so I think I am missing something. 我做了chmod,但是它不起作用,所以我想我缺少了一些东西。 Kindly help, thanks! 请帮助,谢谢!

Well, just 777 is not the same as the octal representation that *nix uses. 好吧,只有777与* nix使用的八进制表示形式不同。 You need to add the 0 prefix to indicate the number is meant to be octal. 您需要添加0前缀以指示该数字是八进制的。

chmod($arg['org_file'], 0777);

Update 更新资料

The same goes for your call to ->save() : 您对->save()调用也是如此:

->save($arg['org_file'], 0755);

To illustrate: 为了显示:

777  = 1100001001 (01411)
0777 =  111111111

尝试chmod($arg['org_file'],0777);

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

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