Karl53 Posted January 6, 2011 Share Posted January 6, 2011 osCommerce v2.2 RC2 Windows Server 2003 IIS v6.0.x I've read a lot of posts and cannot find a solution to this. All of the downloads from our (new) site are corrupted. We sell software, and the download ext is 'exe'. The files that were uploaded to the server are good, because we can run them on the server and the software installs just fine. So the corruption is occuring during the download. THe downloaded file is about 15 bytes larger than the one hosted on the server. When a user double clicks to run, they see a message that the file is not a valid Windows file. I do NOT have download by redirect turned on because the notes in the source file say that option won't work on Windows. I've made the modifications to "download.php" suggest here: http://www.oscommerce.com/forums/index.php?showtopic=126146&st=0&p=505671 Now the file is the correct size after download but it is still corrupted. The GZIP options is OFF in OSC. The site is GZIPed, but only the static content. (Compression is explicitly off for scripts.) Changing to different browsers has not impact on this problem. Does anyone have downloads working on a Windows server? If so, can you share your secret as how you got it working. This has killed the better part of the day for me. TIA, Karl Link to comment Share on other sites More sharing options...
FIMBLE Posted January 7, 2011 Share Posted January 7, 2011 Out of interest, have you tried to zip the .exe and then download the .zip file? Could be something to do with your PC ecurity settings? Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions Link to comment Share on other sites More sharing options...
Karl53 Posted January 7, 2011 Author Share Posted January 7, 2011 The problem seems to be fixed. First, I observed that the file downloaded was actually a several bytes larger than the size it's suppose to be. I viewed the file in an editor capable of opening 16 mb files (Boxer - boxersoftware.com). The initial bytes of the file was the file's name. After that, all bytes seem to match the original file, byte-for-byte. As mentioned, I made the following changes to "download.php" (see my original post for the link for these changes): // Now send the file with even more header() magic;-) // Date in the past header("Expires: Mon, 26 Nov 1962 00:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: private, no-store, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); // false=don't overwrite but add header // HTTP/1.0 header("Pragma: no-cache"); // I ended up leaving this line of code unchanged. Reference post had this line written as below. // header("Pragma: "); // for stupid IE+SSL problem (IE thinks it mustn't save on SSL if no-cache is set) // Content stuff header("Content-Length: " . filesize(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'])); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $downloads['orders_products_filename']); // end change In addition to the above, I added two lines of code at the end of "download.php" per this post: http://php.net/manual/en/function.readfile.php // Fallback to readfile() delivery method. This will work on all systems, but will need considerable resources ob_clean(); //<--- add this line flush(); //<--- add this line readfile(DIR_FS_DOWNLOAD . $downloads['orders_products_filename']); I know from reading that the problem of corrupt downloads comes up rather regularly. I hope this helps someone else out. Please note, that this fix was applied to code running on Windows Server 2003 and running web server IIS v6.0 and PHP 5.2.10. Link to comment Share on other sites More sharing options...
Karl53 Posted January 31, 2011 Author Share Posted January 31, 2011 Another follow-up to this issue. The patch has not been 100% successful. User's are still reporting corrupted downloads. I know the files on the server are not corrupted because I can give them the URL to the file and they can download it reliably with the HTTP protocol. I made another change. There was one empty line after the last "?>", in the downlaod.php script. I removed that empty line, so that "?>" is on the very last line of the file. Again, upon testing, the downloads work. This is the reference link for this change: http://www.zubrag.com/forum/index.php?topic=465.0 >>>> Downloaded Files are corrupt - Common Problem « on: April 20, 2008, 11:16:56 am » -------------------------------------------------------------------------------- I've read a few comments where after using the script File Download, the file is corrupt. I had the same issue but found the problem and would like to share my findings to help you. I'm running Fedora Core 4, PHP Version 5.04 and IE 6.0.2900 After downloading any file type, txt or binary they were corrupted or not the same as the original. What I have found is there is at least one extra line added to the top of every downloaded file. A little more digging and found that the problem is not with the download.php code but somewhere else and the problem was with what I had done. I added a "include_once" at the top of the file to add in my own defines. The included file is a pure PHP file, meaning it starts with at <?php at the top and the last line is a ?>. However the problem was with what was past the last ?>, line feeds. By including this file those extra line feeds were added to the top of my downloaded file. The Fix : After the ?> in my included file I deleted all the blank lines. Then all was well. Just want to add that File Download version 1.3 works very well. And if I wouldn't have changed anything with it all would have been well. Cheers John >>>>>>> Link to comment Share on other sites More sharing options...
awadballal Posted March 16, 2011 Share Posted March 16, 2011 Karl YOU ARE AMAZING :) i jumped all around the room when the download successful without corrupted :) sorry my poor English but really thaaanks .. regards.. Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2011 Share Posted April 1, 2011 which file are you modifying? what did I miss? Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2011 Share Posted April 1, 2011 ok, I thought I had read somewhere you had said it was NOT on the download.php file. I will try this. I now get errors with only some files... could be because they're heavier. Found this topic: http://www.oscommerce.com/forums/index.php?showtopic=126146&st=0&p=505671 BUT I can't find the php.ini on my server How come the downloads work when they were on the same server in a test folder but not know? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.