[英]chmod the folder to make it writable for the server in php
i am trying to upload a file on server via PHP form. 我正在尝试通过PHP表单在服务器上上传文件。 Data is all working find ad getting image name in DB perfectly but issue is that i am not getting image on server.
数据全部正常工作,发现广告在DB中完美地获得了图像名称,但问题是我没有在服务器上获得图像。
I googled and found that DIR is not writable. 我搜索了一下,发现DIR是不可写的。 I checked with below code:
我检查了以下代码:
$image_folder = $destination_folder . $new_file_name;
if ( ! is_writable(dirname($image_folder))) {
echo dirname($newFileName) . ' must writable!!!';
}
and then to change the permission, i tried using chmod('$destination_folder',0777) but all of a sudden a thought striked to mind that should i give write permissions to all on server. 然后更改权限,我尝试使用chmod('$ destination_folder',0777),但突然间想到了一个想法,我应该向服务器上的所有人授予写权限。
Ideally answer is no but then how can i handle it..?? 理想的答案是不,但是那我该如何处理呢?
you can give permissions 755, 您可以授予权限755,
7 5 5
user group world
r+w+x r+x r+x
4+2+1 4+0+1 4+0+1 = 755
You have to know who is the owner. 您必须知道谁是所有者。 Default makes it sense who creates the folder.
默认使由谁创建文件夹变得有意义。
You can use 755 if php creates the folder (php user is owner: the first 7 = full rights for owner) (recommend) 如果php创建了文件夹,则可以使用755(php用户是所有者:前7位=所有者的完整权限)(推荐)
If eg ftp user is owner, upload via php user with 755 permissions for dir is not enough: php user has no write permissions . 如果例如ftp用户是所有者,则通过具有755权限的dir的php用户上载是不够的:php用户没有写权限 。
可能不是您要寻找的答案,但是如果您发现PHP无法将文件写入文件系统上的任何位置,并且无法为上载设置chmod目录,则始终可以将图像存储在数据库中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.