Дайте разрешение 777 на динамически создаваемый файл в php
Привет, у меня есть скрипт, который динамически создал файл в моем локальном каталоге Пожалуйста, скажите мне, как я могу дать разрешение 777 на этот файл прямо сейчас, он недоступен в браузере
<?php
//Get the file
$content = 'http://dev.aviesta.com.mx/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/b/r/bridal-shoes1.jpg ';
$content1 = explode('/', $content);
$end = end($content1);
echo $end;
//print_r($content1[12]);
//Store in the filesystem.
$my_file = $end;
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
$path = '/var/www/'.$end;
copy($content, $path);
?>
14
Author: Rohit Goel, 2013-01-07
7 answers
Используйте функцию chmod
чмод
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
chmod($file, 0777);
27
Author: Alessandro Minoccheri, 2013-01-07 09:32:36
Использовать chmod()
чтобы установить права доступа к файлам.
3
Author: Oliver Charlesworth, 2013-01-07 09:31:51
Использование:
private function writeFileContent($file, $content){
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
chmod($file, 0777); //changed to add the zero
return true;
}
2
Author: Elton da Costa, 2014-12-05 10:32:14
Дайте разрешение на доступ к динамически создаваемому файлу
$upPath = yourpath;
if(!file_exists($upPath))
{
$oldmask = umask(0);
mkdir($upPath, 0777, true);
umask($oldmask);
}
1
Author: Hiren Makwana, 2015-11-19 09:40:50
Для этого можно использовать chmod().
Например. chmod($my_file, 0777);
0
Author: Thomas Clayson, 2013-01-07 09:32:11
Установите default permission
в каталог u r (т.е. rwx
) с помощью setfacl command
ex: setfacl -d -m o::rwx your/directory/path
Затем любая вещь, которую вы создаете в этом каталоге, требует разрешения rwx
.
0
Author: SameerJ, 2013-01-07 11:29:55
Мы можем даже игнорировать *$ ручка* он все равно создаст файл и скопирует содержимое в $путь
<?php
//Get the file
$content = 'http://dev.aviesta.com.mx/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/b/r/bridal-shoes1.jpg ';
$content1 = explode('/', $content);
$end = end($content1);
echo $end;
//print_r($content1[12]);
//Store in the filesystem.
$my_file = $end;
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
$path = '/var/www/'.$end;
copy($content, $path);
?>
0
Author: Rohit Goel, 2013-01-09 10:10:38