PHP IIS problems downloading file says it is corrupt

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-22T11:26:46Z Indexed on 2010/04/22 11:43 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

Hi,

I am running PHP on IIS 6 with mssql. I have uploaded a file to my webserver through a php script. Upon checking the file on the server the file is ok and not corrupt. However, when i then have a link on my website to try and download the file, it says the file is corrupt.

I know the file isnt corrupt as i can view it perfectly if i look at the file on the server.

Is seems like this is a common problem as a similar problem was posted here:

http://www.bigresource.com/Tracker/Track-php-1pAakBhT/

Any help would be much appreciated.

Thanks,

M

My download code is as follows:

$filesize = $rows->filesize;
$filepath = $rows->filepath;

header("Content-Disposition: attachment; filename=$filename");
header("Content-length: $filesize");
header("Content-type: application/pdf");
header("Cache-control: must-revalidate");
header("Content-Description: PHP Generated Data");

readfile($filepath);

© Stack Overflow or respective owner

Related posts about php

Related posts about iis