Jump to content

How to fix corrupt / incomplete digital downloads...


Al Brookbanks

Recommended Posts

Hi,

Hopefully people will find this useful. If your digital download aborts before the file is complete it is because the memory allocated to the php script is all used up.

A typical scenario is that the file is say 4.5MB but only 1.9MB is downloaded.

To fix it open /download.php and find:

readfile($download[0]['digitalDir']);




Replace this with:


function readfile_chunked ($filename) {

			  $chunksize = 1*(1024*1024); // how many bytes per chunk

			  $buffer = '';

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

			  if ($handle === false) {

			   return false;

			  }

			  while (!feof($handle)) {

			   $buffer = fread($handle, $chunksize);

			   print $buffer;

			  }

			  return fclose($handle);

			} 



			readfile_chunked($download[0]['digitalDir']);

I hope people find that useful.

Link to comment
Share on other sites

  • 3 months later...
Guest faxinadu

something is not right,

i have this problem too, and i was going to do this suggested fix only to find it has already been done on my files, assuming this fix was included officially in a cubecart release after this post was written?

anyhow, i still have this problem even with the above code in place.

any thoughts?

Link to comment
Share on other sites

  • 1 year later...
Guest faireymel

I just started using digital and have this error and this fix is already included in my files. What happens now? CCV3.0.17

Thanks for anyone who helps.

Link to comment
Share on other sites

Guest groovejuice

Usually this problem is from having an incorrect path in your digital product set-up, filenames that don't match (paths are case sensitive), or too many characters in the folder/filename, or symbols that aren't alpha-numeric.

1. Ensure the path is correct. Use your root directory if possible (same level as html or web directory -not in it)

2. Be consistent when naming folders and files - I use lower case when possible. Avoid spaces in names and keep the filenames short.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...