jquery插件uploadify多图上传功能实现代码

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>UploadiFive Test</title> <script src="https://www.jb51.net/jquery2.js" type="text/javascript"></script> <script src="https://www.jb51.net/jquery.uploadify.min.js" type="text/javascript"></script> <link type="text/css" href="https://www.jb51.net/uploadify.css"> <style type="text/css"> body { font: 13px Arial, Helvetica, Sans-serif; } </style> </head> <body> <h1>Uploadify Demo</h1> <div> <form> <div> <div> <input type="file" multiple="true"> </div> </div> </form> </div> <a href="javascript:;"> 点击 </a> <script type="text/javascript"> <?php $timestamp = time();?> $(function() { var i=2; $('.clickUpload').click(function(){ var html=''; html+='<div><input type="file" multiple="true"></div>'; $('.form_file').append(html); $('#file_upload'+i).uploadify({ 'formData' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'swf' : 'uploadify.swf', 'uploader' : 'uploadify.php', 'width' : '120', 'fileTypeExts': '*.gif; *.jpg; *.png', 'buttonText': '上传图片', 'removeCompleted' : false, 'multi' : true, //允许多图上传 //上传成功后执行 'onUploadSuccess': function (file, data, response) { $('#' + file.id).find('.data').html(' 上传完毕'); } }); i++; }) $('#file_upload1').uploadify({ 'formData' : { 'timestamp' : '<?php echo $timestamp;?>', 'token' : '<?php echo md5('unique_salt' . $timestamp);?>' }, 'swf' : 'uploadify.swf', 'uploader' : 'uploadify.php', 'width' : '120', 'fileTypeExts': '*.gif; *.jpg; *.png', 'buttonText': '上传图片', 'removeCompleted' : false, 'multi' : true, //允许多图上传 //上传成功后执行 'onUploadSuccess': function (file, data, response) { $('#' + file.id).find('.data').html(' 上传完毕'); } }); }); </script> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzxwpw.html