gen*_*sis 11
$current_count = file_get_contents('count');
$f = fopen('count', 'w+');
fwrite($f, $current_count + 1);
fclose($f);
header("Location: file.zip");
Run Code Online (Sandbox Code Playgroud)
download.php使用以下内容创建一个名为的文件:
<?php
$Down=$_GET['Down'];
?>
<html>
<head>
<meta http-equiv="refresh" content="0;url=<?php echo $Down; ?>">
</head>
<body>
<?php
$filePath = $Down.".txt";
// If file exists, read current count from it, otherwise, initialize it to 0
$count = file_exists($filePath) ? file_get_contents($filePath) : 0;
// Increment the count and overwrite the file, writing the new value
file_put_contents($filePath, ++$count);
// Display current download count
echo "Downloads:" . $count;
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在另一个页面中放置一个链接,将该文件作为参数下载:
download.php?Down=download.zip