One or more files-php

Source: Internet
Author: User
Upload one or more files-php? & Lt ;? Php ** author Coco * date 2011-1-20 *** $ field specifies the input field name in the form * $ type specifies the file type to be uploaded * $ dir specifies the file storage path, relative to the site root path (start and end with) * $ maxsize limits one or more files to be uploaded-php

?

 0 & $ file [size]> $ maxsize) return "size"; if (! Is_dir ($ dir) mkdir ($ dir); list ($ second, $ unix) = explode ("", microtime (); $ name = $ unix. ($ second * 100000000 ). strstr ($ file [name], ". "); // rename the uploaded file by time, accurate to microsecond move_uploaded_file ($ file [tmp_name], $ dir. $ name); return $ name;}/** $ field specifies the input field name in the form ending with [], for example, image [] */function uploadfile_table ($ field, $ type, $ dir, $ maxsize = 0) {if ($ _ FILES [$ field]! = Null) {$ file = $ _ FILES [$ field]; $ count = count ($ file [name]); $ arr = array (); if (! Is_dir ($ dir) mkdir ($ dir); for ($ I = 0; $ I <$ count; $ I ++) {if ($ file [error] [$ I] = 1) {$ arr [$ I] = "error"; continue;} if ($ type! = Strstr ($ file [type] [$ I], "/", true) {$ arr [$ I] = "type"; continue ;} if ($ maxsize> 0 & $ file [size] [$ I]> $ maxsize) {$ arr [$ I] = "size"; continue ;} list ($ second, $ unix) = explode ("", microtime (); $ name = $ unix. ($ second * 100000000 ). strstr ($ file [name] [$ I], ". "); move_uploaded_file ($ file [tmp_name] [$ I], $ dir. $ name); $ arr [$ I] = $ name;} return $ arr ;}} echo"
"; // Print_r (uploadfile (" upimage "," image ", $ _ SERVER ['document _ root']. "/picture/", 5120); // upload a single file print_r (uploadfile_table ("upimage", "image", $ _ SERVER ['document _ root']. "/picture/"); // upload multiple file echo"
"?>

?

 Upload multiple files 
?

?

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.