Home  >  Article  >  Web Front-end  >  Ajaxupload implements multiple file upload operations

Ajaxupload implements multiple file upload operations

php中世界最好的语言
php中世界最好的语言Original
2018-03-31 10:18:021550browse

This time I will bring you Ajaxupload to implement multiple file upload operations. What are the precautions for Ajaxupload to implement multiple file upload operations? The following is a practical case, let’s take a look.

Without further ado, I will post the code directly for you. The specific code is as follows:

<pre name="code" class="php"><?php 
$ele = $_GET[&#39;ele&#39;]; 
$file = $_FILES[&#39;thumb_&#39;.$ele]; 
$pathinfo = pathinfo($file[&#39;name&#39;]); 
$filedir = &#39;uploads/&#39; . date(&#39;Y&#39;); 
if (!is_dir($filedir)) 
{ 
  mkdir($filedir); 
} 
$filedir .= &#39;/&#39; . date(&#39;md&#39;); 
if (!is_dir($filedir)) 
{ 
  mkdir($filedir); 
} 
$filedir .= &#39;/&#39; . time() . &#39;_&#39; . mt_rand(1000, 9999) . &#39;.&#39; . $pathinfo[&#39;extension&#39;]; 
$msg = &#39;&#39;; 
if (!move_uploaded_file($file[&#39;tmp_name&#39;], $filedir)) 
{ 
  $msg = &#39;上传失败&#39;; 
} 
$data = array(&#39;msg&#39; => $msg, 'filedir' => $filedir); 
sleep(2); 
echo json_encode($data); 
?>

  Ajax上传


添加 
 


 

 


 

 


 

 

I believe you will read the case in this article You have mastered the method. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Asynchronous implementation of ajax file upload form

Asynchronous implementation of ajax file download

The above is the detailed content of Ajaxupload implements multiple file upload operations. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn