473,231 Members | 1,958 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,231 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 2560
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.