将文件保存到 xampp htdocs 目录时权限被拒绝

Permission denied when saving a file to xampp htdocs directory

你好,我有这个问题,我正在尝试将文件保存到 htdocs 上的目录,但它说权限被拒绝。

  <?php


$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');
file_put_contents('./images/myFile.gif', $image);

您必须允许将图像插入 htdocs 中的特定文件夹的权限 举个例子 在 ubuntu

sudo chmod 644 /opt/lampp/hdocs/yourfolder

同样,您必须授予访问该特定文件夹的权限