PHP File_put_contents无法正常工作 [英] PHP File_put_contents not working
问题描述
检查此代码:
<?php
$url = 'http://www.example.com/downloads/count.txt';
$hit_count = @file_get_contents($url);
$hit_count++;
@file_put_contents($url, $hit_count);
header('Location: wmwc.zip');
?>
@file_get_contents
正常工作,并且对已下载文件的标头位置进行更改也可以,但是hit_count增加或@file_put_contents
不起作用,因为文件的数量没有增加1.将文件许可权设置为777,但是当我尝试将目录许可权设置为777时,我也收到500内部服务器错误,提示服务器遇到意外状况,阻止了其满足请求."
@file_get_contents
is working fine and the header location change to the downloaded file also works, but either the hit_count increase or @file_put_contents
isn't working, because the number with the file doesnt increase by 1. I've set the file permission to 777, but when I try to set the directory permission to 777 also I get a 500 internal server error saying "The server encountered an unexpected condition which prevented it from fulfilling the request."
推荐答案
您无法通过http写一个远程文件.(如果可以这样做,其他所有人也可以更改该文件)
You can't write a remote file via http.(If you could do that, every one else could change that file also.)
您需要使用本地路径.
这篇关于PHP File_put_contents无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!