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

#   onBeforeDownload no longer work in hikashop 2.5.0

##

- **[tgdkere2](/forum/user/8136-tgdkere2 "View tgdkere2's Profile")**
- [![tgdkere2's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/8136-tgdkere2 "View tgdkere2's Profile") Topic Author
- [ Offline](/forum/user/8136-tgdkere2)

Less More

- Posts: 82
- Thank you received: 5
-
-

11 years 3 months ago [\#211140](#211140) by [tgdkere2](/forum/user/8136-tgdkere2 "View tgdkere2's Profile")  *[onBeforeDownload no longer work in hikashop 2.5.0](/forum/30-integrations/878681-onbeforedownload-no-longer-work-in-hikashop-2-5-0#211140 "-- HikaShop version -- : 2.5.0 -- Error-message(debug-mod must be tuned on) -- : File not found  Hi,  I used a trigger onBeforeDownload and set the filename.  The filename goes up one level. e.g.  $filename = '../audios/mp3/file1.mp3'  Since hikashop 2.5.0 this does no longer work. It worked before. Now, it looks like I can not go one level up in path. I need to go one level up in path hierarchy....  Please advise how to solve this. Why does it no longer work ????  BR")* was created by *[tgdkere2](/forum/user/8136-tgdkere2 "View tgdkere2's Profile")*

-- HikaShop version -- : 2.5.0
-- Error-message(debug-mod must be tuned on) -- : File not found

Hi,

I used a trigger onBeforeDownload and set the filename.

The filename goes up one level. e.g.

$filename = '../audios/mp3/file1.mp3'

Since hikashop 2.5.0 this does no longer work.
It worked before. Now, it looks like I can not go one level up in path.
I need to go one level up in path hierarchy....

Please advise how to solve this. Why does it no longer work ????

BR

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ludGVncmF0aW9ucy84Nzg2ODEtb25iZWZvcmVkb3dubG9hZC1uby1sb25nZXItd29yay1pbi1oaWthc2hvcC0yLTUtMD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

11 years 3 months ago [\#211141](#211141) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[onBeforeDownload no longer work in hikashop 2.5.0](/forum/30-integrations/878681-onbeforedownload-no-longer-work-in-hikashop-2-5-0#211141 "-- HikaShop version -- : 2.5.0 -- Error-message(debug-mod must be tuned on) -- : File not found  Hi,  I used a trigger onBeforeDownload and set the filename.  The filename goes up one level. e.g.  $filename = '../audios/mp3/file1.mp3'  Since hikashop 2.5.0 this does no longer work. It worked before. Now, it looks like I can not go one level up in path. I need to go one level up in path hierarchy....  Please advise how to solve this. Why does it no longer work ????  BR")*

Hi,

The security for the "sendFile" function has been increased.
The function only accept to send file which are in the upload folder or in the secure upload folder : Code:

if(strpos($filename, '..') !== false) return false; $clean_filename = JPath::clean($filename); $secure_path = $this-&gt;getPath('file'); if((JPATH_ROOT != '') &amp;&amp; strpos($path, JPath::clean(JPATH_ROOT)) !== 0 &amp;&amp; strpos($clean_filename, JPath::clean($secure_path)) !== 0) return false;

So if, during the trigger "onBeforeDownloadFile", you want to send a file which is not in that path, the best is to send the file directly : Code:

clearstatcache(); $size = filesize($filename); $fileinfo = pathinfo($filename); ob_end_clean(); ob_start(); $name = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ? preg_replace('/\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) : $fileinfo['basename']; header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $name . '"'); header('Content-Length: ' . $size); header("Cache-Control: maxage=1"); header("Pragma: public"); header("Content-Transfer-Encoding: binary"); $config = hikashop_config(); if($config-&gt;get('deactivate_buffering_and_compression', 0)) { ini_set('output_buffering', 0); ini_set('zlib.output_compression', 0); while(ob_get_level()) @ob_end_clean(); } $fp = fopen($filename, 'rb'); fseek($fp, 0); if(!ini_get('safe_mode')) set_time_limit(0); while(!feof($fp)) { print(fread($fp, 8192)); @ob_flush(); flush(); } fclose($fp); $dispatcher = JDispatcher::getInstance(); $dispatcher-&gt;trigger('onAfterDownloadFile', array( &amp;$filename, &amp;$file)); exit;

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2ludGVncmF0aW9ucy84Nzg2ODEtb25iZWZvcmVkb3dubG9hZC1uby1sb25nZXItd29yay1pbi1oaWthc2hvcC0yLTUtMD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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.067 seconds

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