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
File Upload for video only
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: File Upload for video only
The same way you restrict the file type for images do it the same for the video extensions.
There is no difference.
There is no difference.
Re: File Upload for video only
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.
@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.
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: File Upload for video only
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.
After reading the other article I understand what you mean. I will ask some colleagues at work today and get back to you.