Jump to content

(Solved) Downloadable Products - Maxfile size


Recommended Posts

Hi,

All the products in my store are downloadable. One is 130MB. My hosting provider has a max upload file size of 32MB for PHP. I can however upload any size I want from the admin interface of my hosting account. As my hosting provider uses CPanel I can not change the PHP settings.

I tried to get around the problem, by creating a file with the same name and of the same type (.zip) as the 130MB file but just a few KB and uploading that. I tested this and it downloads fine. I then replaced the file keeping the same file name that was generated with the 130MB file.

However this will not download.

Should this have worked? if not is there another way around the PHP upload size restriction?

Thanks
Simon

Link to comment
Share on other sites

Yes there is, you can use ini_set();

Try adding the following lines to a new php file first to see if it works (open it in your browser.

<?
ini_set('upload_max_filesize','150M');
ini_set('post_max_filesize','150M');
set_time_limit  (3600);
phpinfo();
?>



Scroll down to the line with upload_max_filesize and see if one of the values there is changed (one should be the default still at 32, and the other should show 150).

It this works, copy those lines (except phpinfo()) to the top of /admin/adminCatalog.php

You may also need to increate the values of these 2 lines in adminProduct.php (line18,19)

protected $maxImageSize = 2000000;
protected $maxFileSize  = 10000000;

Link to comment
Share on other sites

Thanks for the response. I had a talk with my hosting provider and they told me to setup a php.ini file in the admin folder for prestashop. Any settings that I put in this file will override the primary PHP file.

I have tried it and sure enough prestashop shows me that I can now upload up to 200MB. I have just tried uploading the 138MB file and that failed with "Big Error"

I have also tried it with a 47MB file and still get a "Big Error"

Any ideas what other PHP settings I may need to change.

Thanks
Simon

Link to comment
Share on other sites

I'm not getting the big error any more. By the way "Big Error" is the error message that prestashop gives you when you try to upload a file that is bigger than your PHP settings will allow.

Everything seems to be working with the upload, but I get the following error when downloading from either the backend or frontend. It is as though prestashop is trying to display the file as a web page. I have tried right clicking and save link as. The save dialog box opens with the correct file name, but it just saves an empty file.

The error message I'm getting is

This web page is not found.

No web page was found for the web address: http://www.etech-training.co.uk/freepbxtrg/get-file.php?key=0fa6c45cec987e22d515a05feef9c6cb40ed3eba-b3118d3dc94a4121dec3cb10b2c5cb1ec7c54e69

More information on this error


I have also added a screen shot of the error

Any suggestions on what I might be doing wrong?

Thanks
Simon

17572_Tob4g1zCkz7xl5URU22U_t

Link to comment
Share on other sites

Not sure if I have discovered a bug while trying to sort out this download issue.

If I upload a MP3 or JPG image everything works fine and as expected.

If I upload a .zip or a office .ods file prestashop downloads get-file-admin.php it seems it only works with popular file names and .zip is not one of them apparently.

Is there is filter to only allow uploading and downloading of certain file types.

Thanks
Simon

Link to comment
Share on other sites

OK, I have a solution(work around) to this issue of file size. It seems to be related to PHP not being able to handle such large files with the readfile() command, which is what prestashop uses to deliver the downloadable files.

Create your product as normal and upload a small file of the same filename. (just open notepad and save an empty document with the file name and extension you want)

you then need to edit get-file.php

At the very end of the file comment out all the lines of code starting with header and enter this line instead

header("location: http://www.yourserver.com/a_web_readable_folder_outside_of_the_prestashop_structure/" . $filename)

Then you need to copy the file you want customers to be able to download to the folder you have created. Dont bother naming it with that great big hash file name that prestashop uses.

Now when customers click to download a file, they will get the file from the folder you created. Dont worry they will not be able to see folder the file came from.

Hope this helps someone

Prestashop, can you look at this and try to include a fix that will allow the downloading of larger files.

Thanks

Link to comment
Share on other sites

Thanks Tomerg,

I have just tried adding ob_end_flush() and it works like a treat.

If that could be incorporated into the next release it would be great.

Thank you

Simon


That's great, that command tell php not to load the entire file into memory, which was causing the problem...

I am not a part of the Prestashop team, so the only thing I can do (much like everyone else) is submit a bug report, and include the solution.
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Humm can this work with large file size such as standard 4.7G DVD size? I am thinking to use PresShop for my software business but after looking into such big issue it gives me a thought that this will be very unstable for file in such size... 4.7GB or beyond... blu-ray file size!!!

Unlike ASPDotNetStoreFront, one of the best commercial software that will give you two choices, use upload funciton for smaller type file size, even though when theyd said "small" meaning it's up to 700MB (CD size)! Still overcome the limitation that lots of shopping cart has, and second choice is the "file-on-server" function, so for large file such as DVD, you can choose, and hit "convert" then the ASPDotnetStoreFront will convert file name into coding format without even "upload"ing!

But ASPDotNetStoreFront is very very expensive, $1,400 US Dollars, guess because they have 120 paid team of programmers working around the clock in different countries and 6,000 developers partner with them sharing their lines of codes for any issues they might have, but I'm sure Prestashop should have some solution on this? Money shuld not be the issue how programming can be done, since I don't mind sharing mine, although some people won't agree with me lol...

Anyway, any suggestions on how this can be done? Thank you in advance!!

Link to comment
Share on other sites

  • 1 month later...

Hi,
Sorry for my English. (j'ai traduit avec Google Translate). Me, my clients must be able to transfer 300MB

1 - I created a php.ini file with

upload_max_filesize = 500M
post_max_size = 500M
set_time_limit = 9000



2 - I added this code in the file "config.inc.php" :

@ini_set('upload_max_filesize', '500M');
@ini_set('post_max_filesize','500M');
@set_time_limit  (9000);



3 - I try adding the following line right before the readfile() call in get-file.php line #106 :

ob_end_flush() 



4 -I added two lines in lines 9 and 10 of the file "adminproducts.php":

protected $maxImageSize = 2000000;
protected $maxFileSize  = 10000000



I tried everything but it still does not work. The transfer works well below 2 MB. But when I try to upload a larger file that does not work :(

Can you help me please ?

Link to comment
Share on other sites

  • 1 month later...
OK, I think I have a solution for you, try adding the following line right before the readfile() call in get-file.php line #106

ob_end_flush()



Let me know if it works....



Hello Tomerg3,

I would try your "ob_end_flush()" but, could you tell me please where exactly I have to place it?

elseif (function_exists('mime_content_type'))
       $mime_type = @mime_content_type ($file);
elseif (function_exists('exec'))
   $mime_type = trim(@exec('file -bi '.escapeshellarg($file)));



Thank you very much by advance! That fix would help me a lot :)

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

Hi guys. Finally solved (I hope).

I tried the trick of renaming a file uploaded with FTP in the "download" folder, using the .rar compression instead of .zip. I also copied php.ini in the "admin" folder with max_file_size upgraded to (whatever extent you need). I tried the trick with .zip first, it downloaded a "corrupted file". Being stubborn, I started again with a different extension (.rar) and everything is fine. I've tried 13 downloads from different computers with different systems and different browsers; Everything's perfect.

Thanks for you all your advice guys.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...