test if mp3 file exists and offer link to allow it to play

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trix.1210
Forum Newbie
Posts: 1
Joined: Sun Feb 10, 2008 1:11 pm

test if mp3 file exists and offer link to allow it to play

Post by trix.1210 »

I have a record shop written in html and javascript and some php at http://www.trixysvinyl.com

heres the page im working on: http://www.trixysvinyl.com/info1.php?view=tv598

heres the php variable:

$view="tv598"

...which ill read from the URL.

I need some php code that looks to see if the following files are in the sf folder on the server

tv598a1.mp3
tv598a2.mp3
tv598a3.mp3
tv598b1.mp3
tv598b2.mp3
tv598b3.mp3

They will be sound samples ill record and store in the sf folder.

I need some php pcode which will look to see if any of these files exist in the sf folder and then display a link to them on the screen. The user then clicks the link and the web page will open up the mp3 in the default mp3 player and play it.

I guess Ill need a for..next loop for this.

I'm a newbie with php.

Any help appreciated - oh - and a free record from my shop under £10 to the 1st person who gives me a successfull solution!!

Thanks

Trixytrix1210
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: test if mp3 file exists and offer link to allow it to play

Post by JAM »

You could use file_exists($view.'.mp3') to check for... file existance... instead of a loop.

Edit; If you don't want to learn and just need the actual code, you could post a question in the job-searching-part of the forums.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: test if mp3 file exists and offer link to allow it to play

Post by Christopher »

That a look at the glob() function.
(#10850)
Post Reply