473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Hiding the link of source file for mp3

18
Hi All,

I am working on a social networking site.And there is a option for playing mp3
musics. But now there is a problem. The link of that file is visible when someone goes through source of that page from view source. I want some ways to hide that path so that link cant be used as direct downloading option.

Thanks and regards
codexxx
Nov 7 '08 #1
1 2016
pbmods
5,821 Expert 4TB
Heya, Codexxx.

On the page that contains the link to the MP3 file, send a token to the User's session and add it to the MP3 link:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $_SESSION['mp3token'] = uniqid('name_of_mp3_file_hashed_with_username');
  3. ?>
  4.  
  5. <a href="/path/to/mp3.php?fileid=12345&amp;token=<?php echo $_SESSION['mp3token'] ?>">mp3 file!</a>
  6.  
In mp3.php:
Expand|Select|Wrap|Line Numbers
  1. if( $_GET['token'] == $_SESSION['mp3token'] )
  2. {
  3.   header('Content-type:  audio/mpeg');
  4.   readfile('.../' . getMP3Filename($_GET['fileid']));
  5. }
  6.  
  7. unset($_SESSION['mp3token']);
  8.  
You could alternatively store the token in a database. The download link is only valid if the User provides a matching token, which he can only do by visiting the page on your site.
Nov 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: R. Rajesh Jeba Anbiah | last post by:
Sometimes ago I started a thread <http://groups.google.com/groups?threadm=abc4d8b8.0404012208.76ebdba7%40posting.google.com> <Previous post> I'm supposed to hide the php extension in a file...
10
by: mark | r | last post by:
anyone know a useful way of hiding image paths so images on my site cant be directly linked to? ive seen sites that use <img src="image.asp?/moo/fred/image01.jpg"> (where the path starts from...
11
by: Lorenzo Villari | last post by:
I premise I don't know C++ well but... I wondered what is this data hiding thing... I mean, if I can look at the header (and i need it beacuse of the class), then what's hidden? Can someone give...
1
by: Steve | last post by:
Hi, I need to provide a button to download a file from my server. However, I would like to hide the location of that file and am not sure how to do this securely with PHP. For example, the user...
8
by: Jho | last post by:
Is it wise to do the following to hide html source and other info. I plan to do a popup window which would close my existing web page and popup a window in its place without toolbar and...
10
by: FX | last post by:
I wanna publish a script on my site which allows me to hide image source. i have rough idea abt it. i`ll point src to some php page like: <img src="image.php"> & in tht php wat exactly shud be...
8
by: Jake G | last post by:
Does anyone know how I can access a variable if I set its value inside <%@ language="javascript" %> <% var whatever = 1234 %> Then later I want to check that variables value to make sure a user...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
1
shoonya
by: shoonya | last post by:
Hi, i am working on a mobile platform written in C. There are certain functions (3rd party codes) called in the source code, which are only present in header (.h file), and their definition is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.