[Skip to main content](#vessel-content)

#   Downloads get corrupted via HiksShop

##

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar_2013-05-19.jpg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

14 years 3 days ago [\#73203](#73203) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  *[Downloads get corrupted via HiksShop](/forum/3-bug-report/73203-downloads-get-corrupted-via-hiksshop#73203 "Hi,  When I download a bought file via HikaShop (ZIP file) it gets corrupted during download. When I download the same file via my own php script, the file is ok.  After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in the corrupted file line 1 is empty. The actual code starts at line 2.  The correct file's code starts at line 1, as it should.  When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.  So somewhere the HikaShop PHP code adds this first emtpy line in the download files.  This is the correct file. See the code starts at line 1  This is the corrupted file. See the code starts at line 2  Please help.  Kind regards, Maurice")* was created by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")*

Hi,

When I download a bought file via HikaShop (ZIP file) it gets corrupted during download.
When I download the same file via my own php script, the file is ok.

After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in
the corrupted file line 1 is empty. The actual code starts at line 2.

The correct file's code starts at line 1, as it should.

When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.

So somewhere the HikaShop PHP code adds this first emtpy line in the download files.

This is the correct file. See the code starts at line 1
[ ![zip-file-okay.jpg](/forum/attachment/6587) ](/forum/attachment/6587 "zip-file-okay.jpg")

This is the corrupted file. See the code starts at line 2
[ ![zip-file-corrupted.jpg](/forum/attachment/6588) ](/forum/attachment/6588 "...-corrupted.jpg")

Please help.

Kind regards,
Maurice

- [ ![zip-file-okay.jpg](/forum/attachment/6587) ](/forum/attachment/6587 "zip-file-okay.jpg") [ ](/forum/attachment/6587?download=1 "zip-file-okay.jpg")
- [ ![zip-file-corrupted.jpg](/forum/attachment/6588) ](/forum/attachment/6588 "...-corrupted.jpg") [ ](/forum/attachment/6588?download=1 "...-corrupted.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC83MzIwMy1kb3dubG9hZHMtZ2V0LWNvcnJ1cHRlZC12aWEtaGlrc3Nob3A/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14280
-
-

14 years 3 days ago [\#73208](#73208) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Downloads get corrupted via HiksShop](/forum/3-bug-report/73203-downloads-get-corrupted-via-hiksshop#73208 "Hi,  When I download a bought file via HikaShop (ZIP file) it gets corrupted during download. When I download the same file via my own php script, the file is ok.  After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in the corrupted file line 1 is empty. The actual code starts at line 2.  The correct file's code starts at line 1, as it should.  When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.  So somewhere the HikaShop PHP code adds this first emtpy line in the download files.  This is the correct file. See the code starts at line 1  This is the corrupted file. See the code starts at line 2  Please help.  Kind regards, Maurice")*

Hi,

HikaShop does not add that empty line.
It must be something else on your website which does.
It's highly possible that it comes from one of your system plugins so I would recommend to disable them one by one and see if that fixes the problem.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC83MzIwMy1kb3dubG9hZHMtZ2V0LWNvcnJ1cHRlZC12aWEtaGlrc3Nob3A/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar_2013-05-19.jpg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

14 years 3 days ago -  14 years 3 days ago [\#73362](#73362) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  Replied by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")* on topic *[Re: Downloads get corrupted via HiksShop](/forum/3-bug-report/73203-downloads-get-corrupted-via-hiksshop#73362 "Hi,  When I download a bought file via HikaShop (ZIP file) it gets corrupted during download. When I download the same file via my own php script, the file is ok.  After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in the corrupted file line 1 is empty. The actual code starts at line 2.  The correct file's code starts at line 1, as it should.  When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.  So somewhere the HikaShop PHP code adds this first emtpy line in the download files.  This is the correct file. See the code starts at line 1  This is the corrupted file. See the code starts at line 2  Please help.  Kind regards, Maurice")*

I disabled each system plugin one by one and testing it. No change.

I even disabled ALL plugins (this breaks the site) and the download is still corrupted.

So even without any plugin enabled, the download still gets corrupted because of this extra empty line at the beginning of the file.

When I open the order in the backend, and I click on the downloadlink, the file gets downloaded correct!

Link in Mail: Code:

http://www.trancewerk-test.nl/index.php?option=com_hikashop&amp;ctrl=order&amp;task=download&amp;file_id=276&amp;order_id=432

Link in Backend: Code:

http://www.trancewerk-test.nl/administrator/index.php?option=com_hikashop&amp;ctrl=order&amp;task=download&amp;file_id=276&amp;order_id=432

Could it have anything to do with permissions?

Maurice

Edit: when I order with my admin account and download via the front-end, I also receive the corrupted file, so I guess it has nothing to do with permissions. Maybe the line-feed handling for front-end downloads is handled wrong somewhere?

Last edit: 14 years 3 days ago by [Maurice](/forum/user/7972-maurice "View Maurice's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC83MzIwMy1kb3dubG9hZHMtZ2V0LWNvcnJ1cHRlZC12aWEtaGlrc3Nob3A/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar_2013-05-19.jpg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

14 years 3 days ago -  14 years 3 days ago [\#73380](#73380) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  Replied by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")* on topic *[Re: Downloads get corrupted via HiksShop](/forum/3-bug-report/73203-downloads-get-corrupted-via-hiksshop#73380 "Hi,  When I download a bought file via HikaShop (ZIP file) it gets corrupted during download. When I download the same file via my own php script, the file is ok.  After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in the corrupted file line 1 is empty. The actual code starts at line 2.  The correct file's code starts at line 1, as it should.  When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.  So somewhere the HikaShop PHP code adds this first emtpy line in the download files.  This is the correct file. See the code starts at line 1  This is the corrupted file. See the code starts at line 2  Please help.  Kind regards, Maurice")*

Hi,

I found the problem. Unfortunately it IS in the HikShop code.

In file administrator/components/com_hikashop/classes/file.php I added two lines of code to fix the problem.

Change this code (around line 326)
Code:

header('Content-Type: application/octet-stream');

into:
Code:

ob_end_clean(); //added to fix ZIP file corruption ob_start(); //added to fix ZIP file corruption header('Content-Type: application/octet-stream');

Save it and now the 'extra' blank line a the top of a downloaded ZIP-file is gone.

Maurice

Last edit: 14 years 3 days ago by [Maurice](/forum/user/7972-maurice "View Maurice's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC83MzIwMy1kb3dubG9hZHMtZ2V0LWNvcnJ1cHRlZC12aWEtaGlrc3Nob3A/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14280
-
-

14 years 1 day ago [\#73613](#73613) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Downloads get corrupted via HiksShop](/forum/3-bug-report/73203-downloads-get-corrupted-via-hiksshop#73613 "Hi,  When I download a bought file via HikaShop (ZIP file) it gets corrupted during download. When I download the same file via my own php script, the file is ok.  After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in the corrupted file line 1 is empty. The actual code starts at line 2.  The correct file's code starts at line 1, as it should.  When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.  So somewhere the HikaShop PHP code adds this first emtpy line in the download files.  This is the correct file. See the code starts at line 1  This is the corrupted file. See the code starts at line 2  Please help.  Kind regards, Maurice")*

Hi,

What you did is not a fix of a bug in HikaShop but a hack to remove the empty line added by something else on your website before letting Hikashop display the content of the file to the browser. So of course, it fixes your problem, but it's circumventing the problem coming from something else.
But I agree that it's a good idea to add that code to avoid other plugins messing with the output of HikaShop.

The following user(s) said Thank You: [Maurice](/forum/user/7972-maurice "View Maurice's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC83MzIwMy1kb3dubG9hZHMtZ2V0LWNvcnJ1cHRlZC12aWEtaGlrc3Nob3A/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.063 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
