Securly uploading videos in PHP [migrated]


This question is about letting a potentially malicious user upload videos to your site – specifically, handling the file itself.

With images, one one simple thing you do (after every other thing is validated) is

    if( $  uploaded_type == 'image/jpeg' ) {         $  img = imagecreatefromjpeg( $  uploaded_tmp );         imagejpeg( $  img, $  temp_file, $  imageQualityPercentage);     }     elseif( $  uploaded_type == 'image/png') {         $  img = imagecreatefrompng( $  uploaded_tmp );         imagesavealpha($  img, TRUE);         imagepng( $  img, $  temp_file, 9*(1-$  imageQualityPercentage/100));     } 

Which basically re-creates the image from user input.

Is there an equivalent in PHP for videos? I’d very much like if mp4/oog/webm ones existed (and supported most codecs), but anyone knows any open source libraries that do this for at least any format/codec?