1、html文档
<!DOCTYPE html>
<!-- release v4.1.8, copyright 2014 - 2015 Kartik Visweswaran -->
<html lang="en"> <head> <meta charset="UTF-8"/> <title>Krajee JQuery Plugins - © Kartik</title> <link href="css/bootstrap.min.css" rel="stylesheet" /> <link href="css/fileinput.css" media="all" rel="stylesheet" type="text/css" /> <script src="js/jquery.min.js"></script> <script src="js/fileinput.js" type="text/javascript"></script> <script src="js/fileinput_locale_zh.js"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> </head> <body> <div class="row" style="height: 500px; width: 500px"> <form enctype="multipart/form-data"> <div class="form-group"> <input id="file-1" type="file" multiple class="file-loading" data-overwrite-initial="false" data-min-file-count="1" > </div>
</html>
2、服务器处理及返回数据
<?php $res = move_uploaded_file($_FILES['file_data']['tmp_name'], 'D:\\lgx\\'.$_FILES['file_data']['name'] ); if ($res){ $result = array( 'state' => 1, 'name' => '这是传递的值', 'path' => '值' ); } else{ $result = array( 'error' => '上传失败' ); } echo json_encode($res);