SHARE
TWEET

[ntpc研習]Upload_2_PHP存檔

Tiebob Jul 11th, 2017 298 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. echo '<pre>';
  3. $img = $_FILES['files'];
  4.  
  5. if(!empty($img))
  6. {
  7.     $img_desc = reArrayFiles($img);
  8.     print_r($img_desc);
  9.    
  10.     foreach($img_desc as $val)
  11.     {
  12.         $newname = date('YmdHis',time()).mt_rand().'.jpg';
  13.         move_uploaded_file($val['tmp_name'],'./uploads/'.$newname);
  14.     }
  15. }
  16.  
  17. function reArrayFiles($file)
  18. {
  19.     $file_ary = array();
  20.     $file_count = count($file['name']);
  21.     $file_key = array_keys($file);
  22.    
  23.     for($i=0;$i<$file_count;$i++)
  24.     {
  25.         foreach($file_key as $val)
  26.         {
  27.             $file_ary[$i][$val] = $file[$val][$i];
  28.         }
  29.     }
  30.     return $file_ary;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top