jQuery¼¼Êõ

jquery File uploadʹÓÃ×ܽᣬjqueryupload

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2015-10-15 15:17 ÎÒÒªÆÀÂÛ( )

jquery File uploadʹÓÃ×ܽᣬjqueryupload¡£jquery File uploadʹÓÃ×ܽᣬjqueryupload 1. jquery file upload ÏÂÔØ jquery file upload Demo µØÖ·£ºhttps://bl

jquery File uploadʹÓÃ×ܽᣬjqueryupload
1. jquery file upload ÏÂÔØ

jquery file upload Demo µØÖ·£ºhttps://blueimp.github.io/jQuery-File-Upload/

jquery file upload ÏÂÔØ   µØÖ·£ºhttps://github.com/blueimp/jQuery-File-Upload/tags

jquery file upload API    µØÖ·£ºhttps://github.com/blueimp/jQuery-File-Upload/wiki/API

2. jquery file upload Ñùʽ

ʹÓÃÁËbootstrap¿ò¼Ü£¬Ñùʽ¿ÉÒԲο¼Demo¡£


×Ô¶¨ÒåµÄÑùʽ£º

<div class="row fileupload-buttonbar" style="padding-left:15px;"> <div class="thumbnail col-sm-6"> <img id="weixin_show" style="height:180px;margin-top:10px;margin-bottom:8px;" src="__PUBLIC__/images/game/game_1.png" data-holder-rendered="true"> <div class="progress progress-striped active" role="progressbar" aria-valuemin="10" aria-valuemax="100" aria-valuenow="0"><div id="weixin_progress" class="progress-bar progress-bar-success" style="width:0%;"></div></div> <div class="caption" align="center"> <span id="weixin_upload" class="btn btn-primary fileinput-button"> <span>ÉÏ´«</span> <input type="file" id="weixin_image" name="weixin_image" multiple> </span> <a id="weixin_cancle" href="javascript:void(0)" class="btn btn-warning" role="button" onclick="cancleUpload('weixin')" style="display:none">ɾ³ý</a> </div> </div> </div>
ÐèÒªÒýÈëµÄjs¡¢cssÎļþ

<link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet"> <!-- CSS to style the file input field as button and adjust the Bootstrap progress bars --> <link rel="stylesheet" href="__PUBLIC__/css/jquery.fileupload.css"> <link rel="stylesheet" href="__PUBLIC__/css/jquery.fileupload-ui.css"> <script src="__PUBLIC__/js/jquery.min.js"></script> <script src="__PUBLIC__/js/vendor/jquery.ui.widget.js"></script> <script src="__PUBLIC__/js/jquery.fileupload.js"></script> <script src="__PUBLIC__/js/jquery.iframe-transport.js"></script>
µ÷Ó÷½Ê½£º

$(function() { $("#weixin_image").fileupload({ url: '__CONTROLLER__/uploadImg', sequentialUploads: true }).bind('fileuploadprogress', function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $("#weixin_progress").css('width',progress + '%'); $("#weixin_progress").html(progress + '%'); }).bind('fileuploaddone', function (e, data) { $("#weixin_show").attr("src","__PUBLIC__/"+data.result); $("#weixin_upload").css({display:"none"}); $("#weixin_cancle").css({display:""}); }); });
url£ººǫ́Ìá½»µÄµØÖ·

fileuploadprogress£ºÖ÷ÒªÊǽø¶ÈÌõµÄÐÞ¸Ä

fileuploaddone£ºÉÏ´«½áÊøºóÖ´ÐеIJÙ×÷

3. ºǫִ́ÐеĴúÂë

ʹÓõÄthinkphp´úÂ룬ÉÏ´«´úÂëºÜ¼òµ¥

public function uploadImg(){ $upload = new \Think\Upload();// ʵÀý»¯ÉÏ´«Àà $upload->maxSize = 3145728 ;// ÉèÖø½¼þÉÏ´«´óС //$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// ÉèÖø½¼þÉÏ´«ÀàÐÍ $upload->rootPath = './Public/Uploads/'; // ÉèÖø½¼þÉÏ´«¸ùĿ¼ $upload->savePath = ''; // ÉèÖø½¼þÉÏ´«£¨×Ó£©Ä¿Â¼ // ÉÏ´«Îļþ $info = $upload->uploadOne($_FILES['weixin_image']); if(!$info) {// ÉÏ´«´íÎóÌáʾ´íÎóÐÅÏ¢ //$this->error($upload->getError()); echo 0; }else{// ÉÏ´«³É¹¦ »ñÈ¡ÉÏ´«ÎļþÐÅÏ¢ //$this->display('templateList'); echo "Uploads/".$info['savepath'].$info['savename']; } }


¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • Thinkphp ½áºÏJquery Ajax¼¼ÊõʵÏÖÎÞˢвéѯ

    Thinkphp ½áºÏJquery Ajax¼¼ÊõʵÏÖÎÞˢвéѯ

    2016-01-15 13:09

  • uploadifyͼ¼¯|uploadify|php+jquery.uploadifyʵÏÖÎļþÉÏ´«½Ì³Ì

    uploadifyͼ¼¯|uploadify|php+jquery.uploadifyʵÏÖÎļþÉÏ´«½Ì³Ì

    2015-11-21 19:06

  • HTML5ÎļþÉÏ´«×é¼þÃÀ»¯jQuery²å¼þ -HTML5¹¦ÄÜ

    HTML5ÎļþÉÏ´«×é¼þÃÀ»¯jQuery²å¼þ -HTML5¹¦ÄÜ

    2015-11-15 10:53

  • PHP+Jquery AjaxUploadʵÏÖÎļþÉÏ´«¹¦ÄÜ´úÂëʵÀý½Ì³Ì

    PHP+Jquery AjaxUploadʵÏÖÎļþÉÏ´«¹¦ÄÜ´úÂëʵÀý½Ì³Ì

    2015-10-14 16:49

ÍøÓѵãÆÀ
Ê