473,387 Members | 1,465 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,387 software developers and data experts.

Audio type

I had a problem with uploading images in that some files did not have a type
of "image/something" from the
$_FILES['the_field_name']['type'] which I used for my verification.
Someone (THANK YOU) suggested using getimagesize() which has the third
element in the returned array being a number representing the image type.
That worked perfectly for me, enabling me to check that it was, indeed, an
image file that I had uploaded.

Now I ask if there is a similar function call for audio types. I want to be
able to verify that the file I upload is, indeed, an audio file. I would
like this function because I am reasoning that if the "type" obtained from
$_FILES['the_field_name']['type'] is not reliable for images, then it
probably isn't reliable for audio either.

Shelly
Jul 26 '05 #1
5 2573
On Tue, 26 Jul 2005 16:34:01 GMT, "Shelly" <sh************@asap-consult.com>
wrote:
Now I ask if there is a similar function call for audio types. I want to be
able to verify that the file I upload is, indeed, an audio file. I would
like this function because I am reasoning that if the "type" obtained from
$_FILES['the_field_name']['type'] is not reliable for images, then it
probably isn't reliable for audio either.


There's the "mime magic" function:

http://uk2.php.net/mime_content_type

... which looks for magic numbers in the file to make a decent guess as to
what format a file is. Not foolproof, but generally reasonable.

The other alternative is presumably doing full parsing of the audio file
itself to look for known structures for the audio formats you're expecting.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 26 '05 #2

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:3k********************************@4ax.com...
On Tue, 26 Jul 2005 16:34:01 GMT, "Shelly"
<sh************@asap-consult.com>
wrote:
Now I ask if there is a similar function call for audio types. I want to
be
able to verify that the file I upload is, indeed, an audio file. I would
like this function because I am reasoning that if the "type" obtained from
$_FILES['the_field_name']['type'] is not reliable for images, then it
probably isn't reliable for audio either.


There's the "mime magic" function:

http://uk2.php.net/mime_content_type

... which looks for magic numbers in the file to make a decent guess as to
what format a file is. Not foolproof, but generally reasonable.


Thanks, I'll try it. I looked at the URL you posted, but couldn't figure
out what to look for to ascertain if it is an audio file. I assume that for
an audio file it will output something like "audio/something" and I could
check for the a match on the first five characters.

Shelly
Jul 26 '05 #3
On Tue, 26 Jul 2005 20:44:13 GMT, "Shelly" <sh************@asap-consult.com>
wrote:
There's the "mime magic" function:

http://uk2.php.net/mime_content_type

... which looks for magic numbers in the file to make a decent guess as to
what format a file is. Not foolproof, but generally reasonable.


Thanks, I'll try it. I looked at the URL you posted, but couldn't figure
out what to look for to ascertain if it is an audio file. I assume that for
an audio file it will output something like "audio/something" and I could
check for the a match on the first five characters.


Yes, that sounds right.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 26 '05 #4

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:ci********************************@4ax.com...
On Tue, 26 Jul 2005 20:44:13 GMT, "Shelly"
<sh************@asap-consult.com>
wrote:
There's the "mime magic" function:

http://uk2.php.net/mime_content_type

... which looks for magic numbers in the file to make a decent guess as
to
what format a file is. Not foolproof, but generally reasonable.


Thanks, I'll try it. I looked at the URL you posted, but couldn't figure
out what to look for to ascertain if it is an audio file. I assume that
for
an audio file it will output something like "audio/something" and I could
check for the a match on the first five characters.


Yes, that sounds right.


A wee bit of a problem. I did it and I get:

Fatal error: Call to undefined function: mime_content_type() in
/home/virtual/site23/fst/var/www/html/ssManageMusic.php on line 118

Now in www.php.net it says that the function is available for
(PHP 4 >= 4.3.0, PHP 5)

I downloaded and checked the php.ini on my server. I saw one comment that
mentioned something for PHP4.3 or greater, so I assume that my server is
running at least PHP 4.3. Any ideas?

Shelly
Jul 26 '05 #5
Shelly wrote:
I want to be able to verify that the file I upload is, indeed, an audio file.
You might look into

http://pecl.php.net/package/fileinfo

or as Andy said, mime_content_type(), which the Manual appears
to have deprecated now and you appear not to have available
right away.
I would like this function because I am reasoning that if the "type" obtained
from $_FILES['the_field_name']['type'] is not reliable for images, then it
probably isn't reliable for audio either.


It's 'not reliable' only insofar as it's straightforward for
somebody to send strange values, or the browser might be
unable to guess the intended type, or the browser might decide
not to give you a Content-Type at all. I would imagine it's
fairly accurate more often than not, although that's not to
say I wouldn't recommend performing further checks.

--
Jock
Jul 27 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rajesh Kapur | last post by:
Hello All, We are building an application that will dynamically choose and pre-pend short underwriting messages to the audio streamed over the web. We will use SMIL files. We need to decide if...
1
by: laredotornado | last post by:
Hello, I want to play an audio file embedded on my page by clicking on an audio image and the page change to a new page. Is there a cross-browser Javascript way to do this? Right now the code I...
0
by: laredotornado | last post by:
Hello, I want to play an audio file by clicking on an audio icon and not having the page switch out underneath. Right now the code I have is ... <html> <head> <title>Dictionary:...
2
by: positivebalance41m | last post by:
I have been searching how to do sound capture (record audio input) in VB.NET for days now. I find some references to "winmm.dll" calls, but they give VB5 or VB6 examples which won't code convert...
3
by: abrtlt | last post by:
I would like to have a web page in which, when the user clicks on any of several specific elements, a specific audio file is played, without reloading the page. The specific audio file name is...
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
1
by: =?Utf-8?B?15DXldeo158=?= | last post by:
I have recently installed my windows XP, the process went smoothly, but I had encounterd some drivers issues after the installation. I managed to solve the ethernet adapter driver issue, but I...
2
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called...
1
by: =?Utf-8?B?bWFsYWs=?= | last post by:
i recently had xp, then isntalled a friends copy of vista then back to xp, but for some reason i cant get no audio device working..i installed the ABIT cd it came with my new motherboard that was...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.