ajax+php (jquery.form插件)实现异步文件上传
<!DOCTYPE html> <html lang="CN"> <head> <title>upload model</title> <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.form.js"></script> </head> <body> <label>Filename:</label> <form id="form" action="upload_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" id="file" /> <input type="button" value="Upload" name="button" id="button"></button> </form> <script type="text/javascript"> $(document).ready(function () { var options = { success: function (data) { $("#responseText").text(data) //responseTest没实际意义 } }; $("#button").click(function () { $("#form").ajaxSubmit(options); }); }); </script> </body> </html>
注意,Jquery最低版本为v1.5
参考:http://www.cnblogs.com/heyuquan/p/form-plug-async-submit.html
可以发牢骚,但是必须要努力奋斗!