在文件上传时更改文件权限 - PHP


Change file permissions upon file upload--PHP?

我有一个PHP上传脚本,并且正在尝试使上传的文件可以被我网站的所有用户编辑和读取(即将上传文件的文件权限设置为chmod 777)。 文件上传到的目录具有正确的权限。但是,上传的文件不会。 由于新文件会不断上传,因此我需要在上传过程中内置某种代码,以便在上传时设置/更改上传文件的文件权限。

有什么想法吗?

只需在上传功能后使用chmod()即可。

<?php
/* 
 * All your upload code here; then pass the filename
 * and the base permissions to the chmod() below
 */
chmod($uploadedFile, 0777);
?>