Hai
Im trying to make a link for mp3 file from some folders. How create a link for these mp3 files by using php code ?

Recommended Answers

All 10 Replies

Can you explain a bit more what you want ? Do you want to search your folders for mp3 files and show a list (with links) ?

What has this to do with mysql?

Can you explain a bit more what you want ? Do you want to search your folders for mp3 files and show a list (with links) ?

yes , and automaticaly call all mp3 files from folder

Hai
Im trying to make a link for mp3 file from some folders. How create a link for these mp3 files by using php code ?

Yes I want all links of mp3 files

See this thread for an example.

its not working
it shows this::::
Warning: opendir(tpl) [function.opendir]: failed to open dir: No such file or directory in /mp3links.php on line 2

That was just an example, I think you need to change 'tpl' to '.'

yah its working thanks alot

Hai
its working well. but a problum that it grab all file from folder like as html page, php page, gif, jpg etc...

<?php 
if ($handle = opendir('uploads')) {
    while (false !== ($file = readdir($handle))) { 
        if ($file != "." && $file != ".." && $file != ".DS_Store" && $file != "list.php") { 
            echo ("<a href=\"uploads/". $file ."\">$file</a><br />"); 
        } 
    }
    closedir($handle); 
}
echo "<br />";
?>

how can find only mp3 file or html page

help me please

Removing the first line (Content-disposition) will cause the browser to play the audio, if it is capable.

header('Content-disposition: attachment; filename=audio.mp3');
header('Content-type: audio/mp3');
readfile('/path/to/audio.mp3');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.