PHP的move_uploaded_file不尊重setgid [英] PHPs move_uploaded_file does not respect setgid

查看:126
本文介绍了PHP的move_uploaded_file不尊重setgid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用函数 move_uploaded_file 移动完成的上传。我注意到这不尊重目标目录的setgid位,并具有该文件原来的。 (我了解到这是Linux行为)。

这个问题有什么好的解决方法?我曾想过把文件加载到PHP并保存,但是这些文件可能相当大,为50MB,这意味着更多的PHP内存使用。

解决方案

您可能或不可以访问系统调用,但是可以访问系统(cp)或即使是一个明确的 chgrp 也可以做你想要的,只要服从setgid位。如果目标目录不同于目标目录,则可能需要进行一些调查才能获得现有的组。


I've moving completed uploads with the function move_uploaded_file. I have noticed this does not respect the target directory's setgid bit and has what the file originally had. (I learnt this is Linux behaviour).

What is a good solution to the problem? I thought about loading the file into PHP and resaving it, but the files can be quite big 50MB+ which means more memory usage for PHP.

解决方案

You may or may not have access to the system call, but a system("cp") or even an explicit chgrp might do what you want, as far as obeying the setgid bit. You might need to do some sleuthing to get the existing group if it varies from target directory to target directory.

这篇关于PHP的move_uploaded_file不尊重setgid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆