Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:15:00+00:00 2026-06-13T04:15:00+00:00

I have been trying to make a music streaming website. I store all the

  • 0

I have been trying to make a music streaming website.

I store all the mp3 in http://www.abc.com/audio folder .

This folder has .htaccess restriction so that none can download any file.

After so much of searching I am unable to find how to play mp3 from this folder using php from this folder.

The PHP code for the play file is filename: play.php

<?php
//print_r($_GET);
include_once('./functions.php');

$path=getPathFromHash($_GET['value']);   //get path from hash_value ex. www.abc.com/audio/1.mp3
echo $track = getFileNameFromHash($_GET['value']);  //get file name ex. 1.mp3

if (file_exists($track)) {
header("Content-Type: audio/mpeg");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: inline; filename=' . $track);
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');
readfile($track);
exit;
} else {
    header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
    echo "no file";
}


?>
<audio src="<?php echo $path?>" autoplay loop controls></audio>

my .htaccess file in audio folder is

<FilesMatch ".(ogg|mp3)$">
Order Allow,Deny
Deny from all
</FilesMatch>

But after all this, the song is not playing 🙁
What changes should I make so that song starts to play?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:15:01+00:00Added an answer on June 13, 2026 at 4:15 am

    You have two problems that I can see:

    1)

    echo $track = getFileNameFromHash($_GET['value']);
    

    Remove the echo from this line. This will cause the file name to be output and will at least corrupt the file data, it will probably prevent the headers from being set correctly as well.

    2)

    You probably need to tell PHP that the files are in the audio/ directory. You say that getFileNameFromHash() returns ex. 1.mp3 – well PHP will look for 1.mp3 in the current working directory, which according to your comment above will be the webroot.

    Try changing the line mentioned above to

    $track = 'audio/' . getFileNameFromHash($_GET['value']);
    

    …which will also mean you should change the Content-Disposition line to:

    header('Content-Disposition: inline; filename="' . basename($track) . '"');
    

    All of this assumes that $path contains a sensible value. It should be /play.php?value=<hash value expected by your functions>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using MVC 2 I have been trying to make this record store project. Creating
I have been trying to make my website performs well. One way that may
I have been trying to make a jQuery function which selects all the checkboxes
Have have been trying to make a validator for my xml files. I have
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I have been trying to make a div fade in evey 30sec and out
I have been trying to make the sub-menu horizontal. In my HTML it looks
I have been trying to make an init script using start-stop-daemon. I am stuck
I have been trying to make this to be a little jQuery plugin that
I have been trying to make a Cross-platform 2D Online Game, and my maps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.