Page 1 of 1

File Upload for video only

Posted: Sun Oct 26, 2008 10:50 am
by legsmacgee
Hello,

I just set up the script for uploading files to my server. This can be dangerous territory, though, and I want to make sure that only video files are uploaded. I know how to restrict files to image files only (ie jpg, gif, etc) but I do not know how to restrict files to video files only (ie .mov, .avi, etc).

Can someone give me a quick code sample showing me how to do this? Thanks!

Legs

Re: File Upload for video only

Posted: Sun Oct 26, 2008 11:15 am
by jaoudestudios
The same way you restrict the file type for images do it the same for the video extensions.

There is no difference.

Re: File Upload for video only

Posted: Sun Oct 26, 2008 5:18 pm
by Hannes2k
Hi,
@jaoudestudios: Restricting the file upload just for extensions isn't sufficient. See this post for an example.

The movies, they are for downloading only or are they for streaming also? If the user just should downloading it, move the files into a protected folder (.htaccess 'deny from all') and uses a php script for providing the download (header + readfile or fopen).

An other way is to check the header of the file. But each format has another header, so this is not an easy job to implement.

Re: File Upload for video only

Posted: Mon Oct 27, 2008 2:46 am
by jaoudestudios
Sorry I did not explain myself well, I did not mean just check the extension (i.e *.txt) as it can be easily faked but check the mime-type of the file.

After reading the other article I understand what you mean. I will ask some colleagues at work today and get back to you.