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 5 2587
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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
"Andy Hassall" <an**@andyh.co. uk> wrote in message
news:3k******** *************** *********@4ax.c om... 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
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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
"Andy Hassall" <an**@andyh.co. uk> wrote in message
news:ci******** *************** *********@4ax.c om... 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_ty pe() in
/home/virtual/site23/fst/var/www/html/ssManageMusic.p hp 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
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_ty pe(), 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the short underwriting messages are better
off stored in a the database (BLOB field?) or in a physical file with the
references stored in the database. How can we load the audio from a
physical file to the database? Is it a good idea to store...
|
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 have
is ...
<html>
<head>
<title>Dictionary: homeostasis</title>
<link href="liveink.css" type="text/css" rel="stylesheet"/>
</head>
|
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: homeostasis</title>
<link href="liveink.css" type="text/css" rel="stylesheet"/>
</head>
<body>
|
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 upgrade to VB.NET without warnings
errors that I can understand how to fix.
There's some ActiveX and OCX's floating around, some free some not, but
in all cases they don't explain or give me access to the raw PCM data
in some kind of familiar...
|
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 obtained from a PHP script (accessing
a MySQL database) that could be called using XMLHttpRequest and
JavaScript would write in a "div" tag an "embed and play" HTML tag
containing the audio file name.
I am not sure this would work, as the embed tag...
| |
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, suggestions or
improvements?
if( wmv file)
document.write("<OBJECT id=Player
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 height="354"
width="479">
|
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 couldn't solve
the audio device problem.
I have tried many programs to detect which audio device I have, and using
this tool : DriverGuide ToolKit, I identified it as realtek audio device.
(I have an Intel motherboard)
|
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 BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the operating system and audio file type, then opens a window with the audio file (passed as a parameter) in...
|
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 isntalled a while ago, but
nothing..i have installed drivers everything and still no device wil appear.
can someone plz help, i hate not having sound, i also have the logitech
z-550 speakers and on vista it worked fine, just when i revert back to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |