[英]FWRITE() Saving file to a specific location
以下代码使用FWRITE功能。 但是我希望将文件保存到特定位置,但始终按预期“打开文件”。 我已经设置了mypath中列出的目录,但它仍然不会写入该位置。
$mypath = "http://www.mysite.com/test/data/";
$myFile = $mypath."data.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Some text";
fwrite($fh, $stringData);
fclose($fh);
尝试使用逻辑路径保存文件,例如:
/家庭/ mysitefolder /的public_html /测试/数据/
还要检查以确保PHP作为Apache运行并具有写入该文件夹的权限。
你的道路是错的; 你不能使用http://
作为路径,你需要像/var/www/test/data
这样的$mypath
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.