PHP Implementation Video File Upload complete example _php skills

Source: Internet
Author: User
Tags php file upload php programming upload php

This paper realizes the function of video file uploading in the form of a complete example. Although it is the basis of the application, there is still a certain reference value. Share for everyone to use for reference. The specific methods are as follows:

First of all, for PHP video also belongs to the file, we use this truth, you can upload a common file with the same way to upload php video files. The difference is that the video file is generally larger, the upload time is long, and PHP configuration file on the size of the upload file is limited.
If you need to better use PHP to achieve file upload, or recommend the use of FTP upload method.

First, the PHP processing code is as follows:

<?php//setting allows up to 10 files to be uploaded at the same time define (' Muilti_file_upload ', ' 10 ');
Set the file size to no more than 5MB define (' max_size_file_upload ', ' 500000 ');
Set up storage directory for uploaded files define (' File_upload_dir ', '/fileuploads '); Allow uploaded file extensions $array _extention_interdite = Array ('. flv ', '. wmv ', '. rmvb ', '. php ', '. PhP3 ', '. PhP4 ', '. exe ', '. msi ')
, '. htaccess ', '. gz '); Public functions that display information function func_message ($message = ', $ok = ') {echo ' <table width= "100%" cellspacing= "0" cellpadding= "0"
 border= "0" >; if ($ok = = True) echo ' <tr><td width= ' 50% ' > '. $message. '
 </td></tr> '; else echo ' <tr><td width= ' 50% ' > '. $message. '
 </td></tr> ';  
Echo ' </table> '; //Process form submission $action = (Isset ($_post[' action '))?
$_post[' action ']: '; $file = (isset ($_post[' file '))?
$_post[' file ']: '; if ($file!= ') $file = $file. '
/';
$message _true = ';
$message _false = ';  
 Switch ($action) {case ' upload ': chmod (file_upload_dir,0777); for ($NB = 1; $nb <= muilti_file_upload; $NB + +) {IF ($_files[' file_ '. $nb] [' size '] >=] {if ($_files[' File_ '. $nb] [' size '] <= max_size_file_upload) {if (!in_ Array (ereg_replace (' ^[[:alnum:]] [-_.]? [[: Alnum:]]
             *. ', '. ', $_files[' File_ '. $nb] [' name '], $array _extention_interdite)}} {if ($_post[' file_name_ '. $nb]!= ')
           $file _name_final = $_post[' file_name_ '. $nb]. $extension;
           else $file _name_final = $_files[' File_ '. $nb] [' name ']; Modify filename $file _name_final = strtr ($file _name_final, ' aaaaaa ', ' aaaaaaceeeeiiiiooooouuuuyaaaaaaceeeeiiiioooooouuu 
           Uyy '); 
           
           $file _name_final = preg_replace ('/[^.a-z0-1]+)/I ', ' _ ', $file _name_final);  
           $_files[' File_ '. $nb [' name '] = $file _name_final;
       
           Start uploading Move_uploaded_file ($_files[' File_ '. $nb] [' tmp_name '], File_upload_dir. $file. $file _name_final); $message _true. = ' File Upload success: '. $_files[' File_ '. $nb [' name ']. ' 
        <br> '; }else $messaGe_false. = ' File upload failed: '. $_files[' File_ '. $nb [' name ']. ' <br> '; }else $message _false. = ' Maximum size of file cannot exceed '. max_size_file_upload/1000.
    ' KB: '. $_files[' File_ '. $nb [' Tmp_name ']. ' <br> ';
}}//end for break; }?>

Two, the HTML code is as follows:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.