Check this code:

<?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 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."

有帮助吗?

解决方案

You can't write a remote file via http.(If you could do that, every one else could change that file also.)

You need to use the local path.

其他提示

try changing directory properties

chown www-data:www-data <dirname>

and/or write as follows, if you host on linux

<?php
$var ="hi";
shell_exec('echo "'.$var.'">>log.txt');
?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top