I am creating a site to host clients files. I have a link they can click on to download a particular file that they have uploaded and when I download a file if it is an image it cannot be opened. If it is a plaintext file it opens but has html tags appeneded to the top. When you click the download link and click save in the Save as Type box it is always HTML. I am pretty sure this should read whatever type of file it is and this is what is causing the problem with opening the file. If I just view the files that have been saved on the server they open fine and everything is good, so I know there isn't an issue with them uploading wrong. My download code is as follows.
header ("Content-length: $size");
header("Content-type: $file_type");
header("Content-Disposition: attachment; filename=$file_name");
readfile($filePath);
The variables are set from an SQL query. I have also tried setting the Content-Type as application/octet-stream and I get the same results. Any ideas?