I'm not sure whether this should go in here or the PHP section. Mod please feel free to move it.
I have a strange problem.
I've got a folder in my public_html directory that contains some zip files.
To block direct access to these files, I have placed a htaccess with this content
Deny from all
I then have a php script where users can download files. This script contains this code:
// Set headers
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".basename($file)."");
header('Content-Length: ' . filesize($file)); // added this line as per suggestion
// Read the file from disk
The problem is, when I have the htaccess. The zip is only being downloaded partially. Without the htaccess it downloads fully. Any idea why this is happening?
Are you using a URL for the value of $file or the system path to the file? I ask because if you using a URL, the htaccess would like affect it, however, if you use C:/mypath/myfile.zip (or the linux variant, /home/myuser/public_html/myfolder/myfile.zip), htaccess shouldn't play a role in accessing the file.
This topic is now closed. New replies are no longer allowed.