1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php中设置文件权限的写法 php图片上传 如何设置文件权限

php中设置文件权限的写法 php图片上传 如何设置文件权限

时间:2021-08-19 22:56:39

相关推荐

php中设置文件权限的写法 php图片上传 如何设置文件权限

我正在上传到777权限文件夹。但是,上载的文件具有664个权限和“nobody”的“owner”。

如何更改以下scipt以将文件上载为777并设置所有者?

代码来自plupload的upload.php文件

if (strpos($contentType, "multipart") !== false) {

if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {

// Open temp file

$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");

if ($out) {

// Read binary input stream and append it to temp file

$in = fopen($_FILES['file']['tmp_name'], "rb");

if ($in) {

while ($buff = fread($in, 4096))

fwrite($out, $buff);

} else

die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');

fclose($out);

unlink($_FILES['file']['tmp_name']);

} else

die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');

} else

die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');

} else {

// Open temp file

$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");

if ($out) {

// Read binary input stream and append it to temp file

$in = fopen("php://input", "rb");

if ($in) {

while ($buff = fread($in, 4096))

fwrite($out, $buff);

} else

die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');

fclose($out);

} else

die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。