PHP File_put_contents不起作用

Cor*_*yRS 0 php file-permissions directory-permissions

检查此代码:

<?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');

?>
Run Code Online (Sandbox Code Playgroud)

@file_get_contents工作正常,标题位置更改为下载的文件也可以,但是hit_count增加或@file_put_contents不起作用,因为文件的数量不会增加1.我已将文件权限设置为777,但是当我尝试将目录权限设置为777我也得到500内部服务器错误说"服务器遇到意外情况,导致无法完成请求".

xda*_*azz 8

您无法通过http编写远程文件.(如果您可以这样做,其他人也可以更改该文件.)

您需要使用本地路径.