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

#   MusicStore mp3 sample - access to files

##

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

Less More

- Posts: 45
- Thank you received: 3
-
-

7 years 1 month ago [\#310908](#310908) by [bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")  *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#310908 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")* was created by *[bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")*

-- HikaShop version -- : HikaShop Business: 4.2.1
-- Joomla version -- : 3.9.11

Hello

we are building a music store that will have mp3 samples.
I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.

How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess
Unfortunately, I do not find the download area, otherwise I could have looked there ...

Very grateful for every tip.
Maya

Code:

&lt;?php // bK Hörprobe echo "&lt;div class='hikaMP3sample'&gt;"; echo "&lt;strong&gt;".JText::_( 'HIKA_MP3_SAMPLE' )."&lt;/strong&gt;"; $songExtension = substr(strrchr($this-&gt;element-&gt;files[0]-&gt;file_path, "."), 1); $songPath = '/media/com_hikashop/upload/safe/'.$this-&gt;element-&gt;files[0]-&gt;file_path; //echo $songPath; if ($songExtension=="mp3"): echo ' &lt;audio controls&gt;'; echo '&lt;source src="'.$songPath.'" type="audio/mpeg"&gt;'; echo '&lt;/audio&gt;' ; endif; echo "&lt;/div&gt;"; ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5ODI4Ni1tdXNpY3N0b3JlLW1wMy1zYW1wbGUtYWNjZXNzLXRvLWZpbGVzP3RtcGw9bWFya2Rvd24=) 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: 86324
- Thank you received: 14288
-
-

7 years 1 month ago [\#310938](#310938) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#310938 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Hi,

If you want to keep the htaccess so that the files of the upload/safe folder cannot be accessed directly, then you need to move your sample files outside of the upload/safe folder.
For example, move them in the upload folder directly, and then change the line: Code:

$songPath = '/media/com_hikashop/upload/safe/'.$this-&gt;element-&gt;files[0]-&gt;file_path;

to: Code:

$songPath = '/media/com_hikashop/upload/'.$this-&gt;element-&gt;files[0]-&gt;file_path;

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

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

Less More

- Posts: 45
- Thank you received: 3
-
-

7 years 1 month ago [\#310958](#310958) by [bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")  Replied by *[bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#310958 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Thank you - but it is imporant that the folder is safe - so therefore it is ok that the files are there. Otherwise an advanced user could grab the files without paying for them.

in the file users&gt;download.php the user is able to download the file somehow - how did you do this?
how was the script allowed to access the files?

Is it not possible to play the song per script, without chaniging the .htaccess?
or do you maybe know if it is possible to "say to the" .htaccess that the script is alow the play the songs, but else it's denied?

still searching for an answer...

Kind regards,
Maya

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5ODI4Ni1tdXNpY3N0b3JlLW1wMy1zYW1wbGUtYWNjZXNzLXRvLWZpbGVzP3RtcGw9bWFya2Rvd24=) 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: 86324
- Thank you received: 14288
-
-

7 years 1 month ago [\#310961](#310961) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#310961 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Hi,

1. It is indeed important that you don't remove the htaccess from the upload/safe/ folder so that the files you sell cannot be accessed directly. And that's why I was proposing that you don't remove it, but instead that you move the sample files outside of that folder. I suppose that it's not a problem that people could potentially download the sample files.

2. To be able to allow the download of files in the upload/safe folder only for people who purchased the files, what we do is we have a PHP script which checks that the current user has the right to download the file. And we change the link to the file so that it goes to this script with the id of the file and the id of the order in the URL so that the PHP script can do its checks. Then, once it's validated, it reads the file in the memory of the server and sends the data itself. That way, the PHP scripts circumvents the htaccess as it doesn't go through apache to read the file but directly reads it on the filesystem of the server.

3. You could potentially do something similar as what I explained in point 2. However here is a simpler approach:
- have all your sample files start or end with a specific text
- use the filesmatch system in your htaccess to deny access to the files not starting/ending with that specific text:
[ www.opentechguides.com/how-to/article/ap...le-dir-security.html](https://www.opentechguides.com/how-to/article/apache/115/htaccess-file-dir-security.html)
That way, you wouldn't have to change your custom code and move the sample files. You could just adapt the htaccess.
Note however that the htaccess will be overwritten when you update HikaShop unless you change its permissions so that it can't be overwritten. So if you can't change its permissions, I would recommend to stick with the solution I proposed in my previous message (and point 1 ).

The following user(s) said Thank You: [bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")

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

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

Less More

- Posts: 45
- Thank you received: 3
-
-

7 years 1 month ago [\#310994](#310994) by [bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")  Replied by *[bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#310994 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Thank you! I will have a look at the different solutions.

At the moment the audition is the whole file and not only a sample (my mistake that I did not say this explicitly)...
maybe we will write a script that cuts the file automaticly and put them in a new folder... I will see!

Thanks a lot for your help!

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

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

Less More

- Posts: 45
- Thank you received: 3
-
-

7 years 1 month ago [\#311333](#311333) by [bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")  Replied by *[bytekultur](/forum/user/4243-bytekultur "View bytekultur's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#311333 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Hello
I have now tried various ways - unfortunately nothing really worked.
At the moment we cut the songs manually and load them back to the server - which is not a solution in the long run.

I took a closer look at the COde of the download.

With the call in the audio player with such a URL I can play a file
hikashop_completeLink ('order &amp; task = download &amp; file_id ='. $ downloadFile-&gt; file_id. '&amp; order_id ='. $ order_id. file_pos $. $ url_itemid)
/ Qflk / kita songs / downloads / order / download / file_id-169 / order_id-74

Now my question - how can I generate such a link myself, which, however, has nothing to do with the download. Is there a documentation in this direction in which direction I could do research?

To really appreciate every tip!

Best regards

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5ODI4Ni1tdXNpY3N0b3JlLW1wMy1zYW1wbGUtYWNjZXNzLXRvLWZpbGVzP3RtcGw9bWFya2Rvd24=) 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: 86324
- Thank you received: 14288
-
-

7 years 1 month ago [\#311336](#311336) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[MusicStore mp3 sample - access to files](/forum/31-development/898286-musicstore-mp3-sample-access-to-files#311336 "-- HikaShop version -- : HikaShop Business: 4.2.1 -- Joomla version -- : 3.9.11  Hello  we are building a music store that will have mp3 samples. I was able to program everything in an override. Only, the upload / safe folder is protected with a .htaccess.  How can I access the mp3 in this folder and have it displayed in the audio. I don't want to switch of the .htaccess Unfortunately, I do not find the download area, otherwise I could have looked there ...  Very grateful for every tip. Maya")*

Hi,

The download controller requires a file entry in the hikashop_file table and based on how the file is configured, it requires an order id of an order with the corresponding product purchased.
So supposing that you add the sample fiel as a "free download" file in the product backend edition interface, you'll get the URL you need to use on the frontend product page.
Supposing that you're editing a view file of the product page via the Display&gt;Views menu, in the variable $this-&gt;element-&gt;files you have an array of all the free download files of the product.
So you can output the links like that: Code:

foreach($this-&gt;element-&gt;files as $file) { echo $file-&gt;download_link; }

And if you want to generate that download link elsewhere, you can do it like that: Code:

hikashop_completeLink('product&amp;task=download&amp;file_id=' . $file-&gt;file_id.$url_itemid);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5ODI4Ni1tdXNpY3N0b3JlLW1wMy1zYW1wbGUtYWNjZXNzLXRvLWZpbGVzP3RtcGw9bWFya2Rvd24=) 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.067 seconds

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