This is only an issue if you're running IIS 6.0 as your web server (or possibly only if you're running on a 64-bit server, but I doubt that). Every time I tried to download a file that had been uploaded to the Documents module, the resulting file would appear to be corrupted and could not be opened by the associated application, even though the file in cache/upload opened fine if I just added the extension to it. This was not an issue on my IIS 5.0 server, however. After pulling my hair out for a couple days, I found a fix for it which only requires one additional line of code in download.php. The ob_end_clean() function removes a prefixed CR/LF pair from file which was causing the application opening it to see the file as corrupt.
I tested this fix on my IIS 5.0 server and the download function still worked. Should be tested on other web servers and added to Sugar source code if it doesn't cause any issues. I'm hoping this saves someone the headache I went through to fix this.![]()
In download.php, insert the following
//Inserted code
ob_end_clean();
//Existing code for placement reference
ob_start();
if (filesize($local_location) < 2097152) {
readfile($download_location);
} else {
readfile_chunked($download_location);
}
@ob_flush();


LinkBack URL
About LinkBacks




Reply With Quote
Bookmarks