Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product download


wer

Recommended Posts

Posted

First off, thanks for the great piece of software, the osCommerce program is awesome. It installed and set up perfectly and I am having fun editing.

 

My problem is with downloading product after it has been purchased. I can download a zip file up to about 9.5 megs but not a file that is 12 megs or larger. (not sure exactly where the limit is but somewhere between the 2) Is this something I can fix within osCommerce or is this a php.ini issue

 

Same with file extensions, I can download, jpg, bmp, pdf, zip but not mp3, it returns as a .php extension, although I can manually change it to mp3 and the file works. Again, this may be a server issue and not something I can fix in the osCommerce files, but I thought I would ask.

Posted

There is always going to be a limit with the d/l size. So you split files into smaller chunks and stream them. As of the extensions you have to enhance the headers based on the file type to download. Both mods should go in the catalog\download.php

Posted

Thanks Enigma, not sure how to do this but I will try to figure it out :-"

 

I was able to get it working by modifying php.ini, [increased post max size to 100M, increased memory limit to 100M and turned on zlib output compression]

 

I also turned on 'use search engine safe urls' in admin

 

I'm not usre exactly which one did it, but some combination of the above and I was able to download a 35 meg powerpoint presentation. It also downloaded as an unkonwn file type, then worked fine when I clicked open.

 

Thanks

Posted
There is always going to be a limit with the d/l size. So you split files into smaller chunks and stream them. As of the extensions you have to enhance the headers based on the file type to download. Both mods should go in the catalog\download.php

 

Well Enigma, you are the man, I hit the next limit when I tried to download a 135 M zipped file

 

So I located the code you posted to someone else

 

Couple of things:

 

1. For the redirect download. In catalog\downloads.php find this code:

symlink(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'], DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename']);
tep_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . $downloads['orders_products_filename']);

 

Replace it with this:

	symlink(DIR_FS_DOWNLOAD . $downloads['orders_products_filename'], DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . basename($downloads['orders_products_filename']));
tep_redirect(DIR_WS_DOWNLOAD_PUBLIC . $tempdir . '/' . basename($downloads['orders_products_filename']));

 

2. For the file size limitation you could enhance the download size so instad of doing a readfile.

readfile(DIR_FS_DOWNLOAD . $downloads['orders_products_filename']);

 

you could use this

  $file = DIR_FS_DOWNLOAD . $downloads['orders_products_filename'];
 $chunksize = 1*(1024*1024); // 1MB chunk
 $buffer = ''; 
 $handle = fopen($filename, 'rb'); 
 if ($handle !== false) { 
while (!feof($handle)) { 
 $buffer = fread($handle, $chunksize); 
 print $buffer; 
} 
fclose($handle); 
 }

 

 

Although it didn't work quite right, there was a slight error in your code

$handle = fopen($filename, 'rb');

should be

 

$handle = fopen($file, 'rb');

 

You defined "$file" then called "$filename", no big deal, when it downloaded an empty file I knew it would work

 

Thank you very much, you've probably answered this same questions a few times B)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...