Fatal error:

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8124

Hello,

i uploaded a file of 80 MB to a Directory outside htdocs. When User try to download it from Hikashop-link, he gets a allowed memory size error:

"Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 80310247 bytes) in /home/vhosts/5000157844/world-of-cinema.net/htdocs/libraries/joomla/filesystem/file.php on line 250"

My memory_limit = 64MB, isn't that enough to download a 80MB File?? I tried other shop-system and download-module and i can download files about 2GB without any problems. What hikashop is doing, is it first try to load file into memory?

Kind regards and thank you for help... Jo

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8125

Hi,

Indeed, for security reasons (so that no one can download the file with just the link to it), the files uploaded in HikaShop are not directly accessible from the outside. So, the only way to access them is to go through HikaShop's code which checks that the user has the right to download it, then load that file in memory and send its content directly to the browser.

So, if you want to allow the download of files in HikaShop, your PHP memory limit needs to be above the size of the files (+ the memory used by joomla and hikashop ).

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8126

Oh, that was a fast answering...

I understand. Unfortunately it's not possible to get memory_limt bigger than 64MB from my hoster. Is there a way to deactivate the user check and download the file directly?

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8128

You can edit the file show of the view order for the front end via the menu Display->Views. There, you can change the line:
$fileHtml = '<a href="'.hikashop::completeLink('order&task=download&file_id='.$file->file_id.'&order_id='.$this->order->order_id).'">'.$file->file_name.'</a>';
by:
$fileHtml = '<a href="'.HIKASHOP_LIVE.'media/com_hikashop/upload/safe/'.$file->file_path.'">'.$file->file_name.'</a>';

And also, delete the file .htaccess in the folder media/com_hikashop/upload/safe so that the files upload folder can be accessible from the outside.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8131

Ok, thank you. But in that case it's not possible to have access to files outside "htdocs", is that right?

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8132

Indeed. Apache does not allow anyone to access files outside your web folder for obvious reasons.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8134

But in other case hikashop can access to files outside htdocs. What can i do to give anyone who get the downloadlink, the rights to download the file outside htdocs?
You see, it's realy important for me.

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8135

When you point to a file directly like http://my_website.com/myfile.zip apache give you back that file directly. Apache prevent anyone from accessing files outside the htdocs directory, there is nothing you can do unless you configure apache differently. But if you can't even change the memory limit of PHP, I doubt that you are allowed to change that either. It's not related to HikaShop, that's something which is related to the way your server is configured.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8136

I understand you, but why is it possible for example with mediashop (other joomla shopsystem), to download files much bigger then memory_limit, from outside htdocs? Thank you again!

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8138

They probably use another technique than us to load and send the file content.

We use the standard joomla function for that and it first loads everything in memory before giving it back to us so that we can send it to the browser.

But we could also use directly the PHP file handling functions to load the file piece by piece and send each piece to the browser before freeing the memory before loading the next one.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8139

This would be the perfect solution! Is it very difficult to realize that in Hikashop? Maybe you can give me an approach?

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8140

Could you try to replace the file amdinistrator/components/com_hikashop/classes/file.php by the one in the archive enclosed ?
We made some modifications to handle the download by chunks instead of using joomla's built-in functions.
It's not tested so there by by some glitches. Please report to us how it goes.

File Attachment:

File Name: file.zip
File Size:4 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8156

I replaced the file.php. Now when i try to start a download (File of 80MB), a window opens and ask me correctly if i want to open or save. But instead of file it shows me the name of the file directory. When i klick ok, download goes just for a second, than Firefox says that the download is finished, but nothing is really downloaded.

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8158

Please try with this one then.

File Attachment:

File Name: file-20110215.zip
File Size:4 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8171

Great, now it really downloads the file! I do it 5 times, unfortunately after every download the size of the downloaded file was to smal and corrupt!

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8176

Could you give us an FTP access to your website and an access on the front end so that we can access an order page and download the file ? That way, we'll be able to test that problem more easily because on our end it's working fine and the file is not corrupt.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8181

ok, how can i do that?

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8182

You can use our contact form: www.hikashop.com/en/support/contact-us.html

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
13 years 10 months ago #8188

Done!

Please Log in or Create an account to join the conversation.

  • Posts: 83025
  • Thank you received: 13404
  • MODERATOR
13 years 10 months ago #8202

We got your email and we're going to look at that :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.089 seconds
Powered by Kunena Forum