Advertisement
Tiebob

[ntpc研習]Upload_2_PHP存檔

Jul 11th, 2017
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement