Javil Posted January 17, 2011 Share Posted January 17, 2011 Hi all, i have trouble with a piece of code. HTML: <div class="psdBox"><a href="downloads/001_PSD.php"><img src="webBuild/psdIcon.png" alt="psd icon" /></a> <div class="phpBox"> <?php $hit_count = @file_get_contents('http://example.com/downloads/001_PSD.txt'); echo $hit_count; ?></div></div> PHP: <?php $url = 'http://example.com/downloads/001_PSD.txt'; $hit_count = @file_get_contents($url); $hit_count++; @file_put_contents($url); header ('Location: http://example.com/downloads/001_PSD.zip'); ?> What i'm trying to do is to count the downloads on my site using PHP without sql. This code working from the root. [www.example.com/here] But if i want this code work from a folder [www.example.com/downloads/here] then i does not work. The 001_PSD.txt won't count up from a folder. In the root, where it works, the chmod of the 001_PSD.txt is standard 0644. This works! I always thought that i must be 0777, but from the root 0644 is ok. When i tested it from /downloads folder, i tried to set 001_PSD.txt to chmod 0777, but that also fails.. Can someone help me to make this work.. i cannot find the problem, i want to make multiple downloads and don't want to put every download in the root folder.. thank, javil Quote Link to comment Share on other sites More sharing options...
JKG Posted January 17, 2011 Share Posted January 17, 2011 do you mean to have .txt .php and .zip for your file extensions in that dir? Quote Link to comment Share on other sites More sharing options...
Javil Posted January 18, 2011 Author Share Posted January 18, 2011 Yes. Example.com\mypage.php. In mypage.php stands this code: <div class="psdBox"><a href="downloads/001_PSD.php"><img src="webBuild/psdIcon.png" alt="psd icon" /></a> <div class="phpBox"> <?php $hit_count = @file_get_contents('http://example.com/downloads/001_PSD.txt'); echo $hit_count; ?></div></div> So yes, the .txt .zip and .php stands in the folder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.