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

Upload file types

I have upload working and the file type test has "audio/mid". I would also
like allow other types, say .wav for example. Is it simply a case of
changing:

if ($_FILES['filename']['type'] == "audio/mid") {

to

if (($_FILES['filename']['type'] == "audio/mid") ||
($_FILES['filename']['type'] == "audio/wav") ) {

Is there a more compact way of doing it?

Also, please help me understand the meaning of "audio/mid". Why is there
the prequalifier of "audio/" and not simply have "mid"? I am sure this is
**somewhere** in the manual, but I haven't located it as yet.

Shelly
Jul 17 '05 #1
4 2106
>I have upload working and the file type test has "audio/mid". I would also

This is a MIME type. You can do any test you want on it.
like allow other types, say .wav for example. Is it simply a case of
changing:

if ($_FILES['filename']['type'] == "audio/mid") {

to

if (($_FILES['filename']['type'] == "audio/mid") ||
($_FILES['filename']['type'] == "audio/wav") ) {

Is there a more compact way of doing it?

Also, please help me understand the meaning of "audio/mid". Why is there
the prequalifier of "audio/" and not simply have "mid"? I am sure this is
**somewhere** in the manual, but I haven't located it as yet.


MIME types have a general class (text, audio, video, etc.) and a
specific format. It is common that something checking the type
is interested in the class but is not particular about the type.
This is particularly true for software that is not necessarily
updated every time someone comes up with a new type.

For example, a browser might send anything of class "audio" or
"video" to the application "mplayer", and let IT worry about whether
it can handle the specific type. Or it might handle a few specific
types that it knows about, e.g. audio/aac, with specific programs,
and let "mplayer" handle the remaining ones matching audio/* or
video/* .

Gordon L. Burditt

Jul 17 '05 #2
Shelly wrote:
Also, please help me understand the meaning of "audio/mid".
its meaning depends on its context. it has the *form* of a
media type, as defined by MIME, but it's an error if it occurs
anywhere a media type is expected, because it hasn't been
registered and doesn't take the form of a private type.

[the rest assumes it is registered]
Why is there the prequalifier of "audio/" and not simply have "mid"?


<audio> (</> is just a separator, without any semantics) is
what's termed a Top-Level Media Type, and usually indicates
the general type of data, whereas <mid> is a Subtype of the
specified top-level one, and usually indicates a specific
format. so <mid> is a 'kind of' <audio>, if you like.

--
Jock
Jul 17 '05 #3
Thank you very much. That was very educational. I will change mine to
audio/*.

Shelly

"Gordon Burditt" <go***********@burditt.org> wrote in message
news:11*************@corp.supernews.com...
I have upload working and the file type test has "audio/mid". I would
also


This is a MIME type. You can do any test you want on it.
like allow other types, say .wav for example. Is it simply a case of
changing:

if ($_FILES['filename']['type'] == "audio/mid") {

to

if (($_FILES['filename']['type'] == "audio/mid") ||
($_FILES['filename']['type'] == "audio/wav") ) {

Is there a more compact way of doing it?

Also, please help me understand the meaning of "audio/mid". Why is
there
the prequalifier of "audio/" and not simply have "mid"? I am sure this is
**somewhere** in the manual, but I haven't located it as yet.


MIME types have a general class (text, audio, video, etc.) and a
specific format. It is common that something checking the type
is interested in the class but is not particular about the type.
This is particularly true for software that is not necessarily
updated every time someone comes up with a new type.

For example, a browser might send anything of class "audio" or
"video" to the application "mplayer", and let IT worry about whether
it can handle the specific type. Or it might handle a few specific
types that it knows about, e.g. audio/aac, with specific programs,
and let "mplayer" handle the remaining ones matching audio/* or
video/* .

Gordon L. Burditt

Jul 17 '05 #4
>Thank you very much. That was very educational. I will change mine to
audio/*.


If you intend matching the type against "audio/*", you can't
use a string comparison for that. You could extract the
part before the / and compare it against "audio". Or you
could use a regex pattern match (against, say, "^audio/.*$").

You need to consider whether you really want to accept the type:
audio/MicrosoftEncryptedProprietaryCopyright2005DoNotCop yOrYoullBeDamnedToHell

Gordon L. Burditt
Jul 17 '05 #5

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

Similar topics

2
by: John | last post by:
I am using Excel to save a spreadsheet in .csv format. This creates a text file with extension .csv But when I try to upload the file to the server by checking for its MIME type using $_FILE I get...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
1
by: lazyadmin | last post by:
I would like to use this code on my website to allow simple file uploads from clients. I would like to restrict the file types they can upload. Can this be done? Any help appreciated. Rod...
3
by: vishpala kadam via .NET 247 | last post by:
Hi, I am using <input type="file"> to upload files in my asp.net application. I want to set the filter so that user can view only .xls files once he/she clicks the Browse button. Is it possible?...
2
by: Manny Chohan | last post by:
Guys, I am giving users to upload files on my server. i have Symantec virus scan on my server running in the background. Now would a user be able to upload document with virus inside it or not...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
3
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be...
18
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? ...
1
by: fortwilliam | last post by:
Hi, I am very new to "object oriented programming". I have this script which I didn't write but have altered and have been using for a while to allow people to upload files to a website. Now I am...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.