FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


detect video and audio files...





AOP Web Development
Hello i just like to know if you have the list of the upload file type for the most common upload file for video and audio file... well actually i have file type on video and audio

video:
Code:
function is_video_file($ufilename){
      $rt = array("video/x-ms-wmv","video/3gpp","video/x-msvideo","video/mpeg");
      if(in_array($_FILES[$ufilename]['type'],$rt))
         return true;
      else
         return false;
   }



it support the ff:

video/x-ms-wmv - wmv
video/3gpp - 3gp
video/x-msvideo -avi
video/mpeg - mpg

on audio:
Code:
   
function is_audio_file($ufilename){
      $rt = array("audio/mpeg","audio/x-ms-wma","audio/wav","video/mpeg");
      if(in_array($_FILES[$ufilename]['type'],$rt))
         return true;
      else
         return false;
   }

and it support the ff.:

audio/mpeg - mp3
audio/x-ms-wma - wma
audio/wav - wav


That functions is detecting the file type in audio and video.. but I know that there are other extension type that can use in uploading the file.. i hope you can add the list of filetype to be support for this function thanks a lot
Ranfaroth
Firstly, you have to know that you can't rely on the $_FILES[$ufilename]['type'] string, as it can be overwritten by user.

Secondly, you can add :
application/ogg for Ogg Vorbis and Ogg Theora.
audio/midi for Midi files.
video/quicktime for some Quicktime files.
AOP Web Development
ah. what do you mean that it can be overwritten by the user? well i tried to use that to validate if the upload file is a video file nor audio file..

Can you explain it elaborately.. thanks a lot. Laughing Laughing
sonam
Ranfaroth wrote:
Firstly, you have to know that you can't rely on the $_FILES[$ufilename]['type'] string, as it can be overwritten by user.


Can you please little bit explain this. Did you mean how user can upload some file what haven't right extension, renamed file with two extensions or wrong file (e.g. .exe) wiht right extension (e.g. .jpg)? Or something else?

Sonam
Ranfaroth
The type property is a HTTP header sent by the browser. So a user can change it easily..
sonam
Ranfaroth wrote:
The type property is a HTTP header sent by the browser. So a user can change it easily..


Sorry, but I don't understand. If I have form with "Browse" button and user atach file from his/her computer how he/she can change header? Can you please give me some useful link or type some useful example. I need this for security reason.

Thanks,
SOnam
AOP Web Development
Ranfaroth wrote:
The type property is a HTTP header sent by the browser. So a user can change it easily..


can you elaborate your thoughts? how can the user change the header sent on the server? if you said that it is possible that they can change it??
Dougie1
sonam wrote:
Ranfaroth wrote:
The type property is a HTTP header sent by the browser. So a user can change it easily..


Sorry, but I don't understand. If I have form with "Browse" button and user atach file from his/her computer how he/she can change header? Can you please give me some useful link or type some useful example. I need this for security reason.

Thanks,
SOnam

Header information can be changed by custom browsers or browsers with extentions. They can also be altered in other ways. Never trust information sent by users.
AOP Web Development
so.. if that is the case how would filter the or to detect the upload files of the user is a video nor audio file... thanks.
musicaty
Great work Thanks
Ranfaroth
As Dougie1 explained, there are several ways to modify the headers sent.
I can add the simple telnet connection...
AOP Web Development wrote:
so.. if that is the case how would filter the or to detect the upload files of the user is a video nor audio file... thanks.
In PHP with Fileinfo Functions, or more easily, on GNU/Linux, with file.
Related topics
A "small" list of free apps
All-In-One convert, author and burn AVI/DivX/Xvid/DV to DVD
Easy Video Capture 1.30
RM to MP3 Converter 1.21 ( cool one )
Which player do you use
PSP - PlayStation Portable
avi to rmvb on Realproducer 10 Plus
What Media Player Do You Use?
Wireless networking advice needed.
Transfer Songs from cassettes to Computer
AviPreview/VideoLan/DivFix - For incomplete video files
Best filemanager?
All Eztoo Products 50% off Discount
Mac Video To Audio Converter special offer
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.