PHP implements a complete example of video file upload. _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags php file upload upload php
PHP implements a complete example of video file upload ,. PHP implements a complete example of video file upload. This article implements the video file upload function in the form of a complete example. Although it is a relatively basic application, it still has some reference value. Complete example of video file upload using PHP,

This document provides a complete example to upload video files. Although it is a relatively basic application, it still has some reference value. Share it with you for your reference. The specific method is as follows:

First, for PHP, video is also a file. we can use this principle to upload PHP video files in a similar way as uploading common files. The difference is that the video file is generally large and the upload time is long, and the php configuration file also has a limit on the size of the file to be uploaded.
If you need to use PHP to upload files, we recommend that you use FTP to upload files.

I. PHP processing code:

<? Php // you can set up to 10 files to upload define ('muilti _ file_upload', '10') at the same time; // you can set the file size to not exceed 5 MBdefine ('max _ SIZE_FILE_UPLOAD ', '000000'); // Set the storage directory of the uploaded FILE ('File _ UPLOAD_DIR ','/fileuploads '); // File extension $ array_extention_interdite = array ('. flv ','. wmv ','. rmvb ','. php ','. php3 ','. php4 ', '.exe ','. msi ','. htaccess', '.gz '); // public function func_message ($ message = '', $ OK ='') {echo'
 
 
  
  
'; If ($ OK = true) echo'
  
  '; Else echo' 
   '; Echo' 
  
'. $ Message .'
'. $ Message .'
';} // 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']> = 10) {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 the file name $ file_name_final = strtr ($ file_name_final, 'aaaaa', 'weight '); $ file_name_final = preg_replace ('/([^. a-z0-1] +)/I ',' _ ', $ file_name_final); $ _ FILES ['File _'. $ nb] ['name'] = $ file_name_final; // Start to upload move_uploaded_file ($ _ FILES ['File _'. $ nb] ['tmp _ name'], FILE_UPLOAD_DIR. $ file. $ file_name_final); $ message_true. = 'File uploaded successfully :'. $ _ FILES ['File _'. $ nb] ['name'].'
';} Else $ message_false. =' file Upload failed: '. $ _ FILES ['File _'. $ nb] ['name'].'
';} Else $ message_false. = 'maximum file size cannot exceed '. MAX_SIZE_FILE_UPLOAD/1000. 'kb :"'. $ _ FILES ['File _'. $ nb] ['tmp _ name']. '"
';}} // End for break ;}?>

II. the HTML code is as follows:

 Php file Upload. Border {background-color: #000000 }. box {background-color: # f8f8f9 ;}. text {color: #000000; font-family: ""; font-size: 12px; font-weight: bold} input, select {font-size: 12px ;} body {margin: 0 ;} 
    

I hope this article will help you with PHP programming.




Upload: This article implements the video file upload function in the form of a complete instance. Although it is a relatively basic application, it still has some reference value. Points...

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.