嗨,我有一个脚本,动态创建我的本地目录中的文件请告诉我如何给予该文件777权限,现在它在浏览器中无法访问
<?php
//Get the file
$content = 'http://xxx.xxx.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);
?>
Run Code Online (Sandbox Code Playgroud)
Ale*_*eri 39
使用chmod chmod函数
$fp = fopen($file, 'w');
fwrite($fp, $content);
fclose($fp);
chmod($file, 0777);
Run Code Online (Sandbox Code Playgroud)