>웹 프론트엔드 >JS 튜토리얼 >Uploadify 플러그인은 진행률 표시줄을 사용하여 일괄 업로드 기능을 만듭니다.

Uploadify 플러그인은 진행률 표시줄을 사용하여 일괄 업로드 기능을 만듭니다.

php中世界最好的语言
php中世界最好的语言원래의
2018-04-26 11:17:591782검색

이번에는 Uploadify 플러그인의 진행률 표시줄이 있는 일괄 업로드 기능을 가져왔습니다. Uploadify 플러그인에서 진행률 표시줄이 있는 일괄 업로드 기능을 만들 때 주의할 점은 무엇인가요? .



  <title>Jquery Uploadify上传带进度条,且多参数</title>
  <link>
  <script></script>
  <script></script>
  <script></script>
  <script>
    $(document).ready(function () {
      $("#pics").hide();
      $("#uploadify").uploadify({
        &#39;uploader&#39;: &#39;js/jquery.uploadify-v2.1.4/uploadify.swf&#39;, //uploadify.swf文件的路径
        &#39;script&#39;: &#39;UploadHandler.ashx?type=add&#39;, //处理文件上传的后台脚本的路径
        &#39;cancelImg&#39;: &#39;js/jquery.uploadify-v2.1.4/cancel.png&#39;,
        &#39;buttonText&#39;: &#39;Select Image&#39;,
        &#39;folder&#39;: &#39;UploadFile/<% = DateTime.Now.ToString("yyyyMMdd") %>/&#39;, //上传文件夹的路径按20130416
        &#39;queueID&#39;: &#39;fileQueue&#39;, //页面中,你想要用来作为文件队列的元素的id
        &#39;auto&#39;: false, //当文件被添加到队列时,自动上传
        &#39;multi&#39;: true, //设置为true将允许多文件上传
        &#39;fileExt&#39;: &#39;*.jpg;*.gif;*.png&#39;, //允许上传的文件后缀
        &#39;queueSizeLimit&#39;: 5,
        &#39;fileDesc&#39;: &#39;Web Image Files (.JPG, .GIF, .PNG)&#39;, //在浏览窗口底部的文件类型下拉菜单中显示的文本
        &#39;sizeLimit&#39;: 1024000, //上传文件的大小限制,单位为字节 1024*1000 1M
        &#39;onComplete&#39;: function (event, queueID, fileObj, response, data) {
          var html = "";
          html += "  <li class=\&#39;myli\&#39;>";
          html += "  <img  src=\"" + response + "\" class=\&#39;myimg\&#39;/ alt="Uploadify 플러그인은 진행률 표시줄을 사용하여 일괄 업로드 기능을 만듭니다." >";
          html += "  <p style=\" position:absolute; right:8px; bottom:5px\">";
          html += "    <img  title=\"点击删除\" src=\"Images/delete.gif\" onclick=\"delImage(\&#39;" + response + "\&#39;);\" / alt="Uploadify 플러그인은 진행률 표시줄을 사용하여 일괄 업로드 기능을 만듭니다." >";
          html += "  ";
          html += "  ";
          $("#pics").append(html);
        },
        &#39;onAllComplete&#39;: function (event, data) { //当上传队列中的所有文件都完成上传时触发
          //alert(data.filesUploaded + &#39; 个文件上传成功!&#39;);
          $("#pics").fadeIn();
        }
      });
    });
    function uploadpara() {
      //自定义传递参数
      $(&#39;#uploadify&#39;).uploadifySettings(&#39;scriptData&#39;, { &#39;name&#39;: $(&#39;#txtName&#39;).val(), &#39;albums&#39;: $(&#39;#txtAlbums&#39;).val() });
      $(&#39;#uploadify&#39;).uploadifyUpload();
    }
    function delImage(picurl) {
      jsonAjax("UploadHandler.ashx", "type=del&picurl=" + picurl, "text", callBackTxt);
    }
    function jsonAjax(url, param, datat, callback) {
      $.ajax({
        type: "post",
        url: url,
        data: param,
        dataType: datat,
        success: callback,
        error: function () {
          jQuery.fn.mBox({
            message: &#39;恢复失败&#39;
          });
        }
      });
    }
    function callBackTxt(data) {
      var o = data;
      if (o != "") {
        var e = $(".myli img[src=&#39;" + data + "&#39;]");
        e.each(function () {
          $(this).parent().remove();
        })
      } else {
        alert("删除失败");
      }
    };
  </script>
  <style>
  .myul
  {
   margin:5px 5px 5px 5px;
   padding:0px;
  }
  .myli
  {
    list-style-type:none;
    width:150px;
    height:150px;
    display:inline;
    position:relative;
  }
  .myimg
  {
    width:120px;
    height:120px;
  }
  </style>


  
  

  

     

  

      
     

  

    上传|     取消上传   

        
using System;
using System.Web;
using System.IO;
/// <summary>
/// UploadHandler文件上传
/// </summary>
public class UploadHandler : IHttpHandler
{
  public void ProcessRequest(HttpContext context)
  {
    context.Response.ContentType = "text/plain";
    context.Response.Charset = "utf-8";
    string type = context.Request["type"];
    if (type=="add")
    {
      HttpPostedFile file = context.Request.Files["Filedata"];
      string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);
      string name = context.Request.Params["name"]; //获取传递的参数
      string albums = context.Request.Params["albums"];
      if (file != null)
      {
        if (!Directory.Exists(uploadPath))
        {
          Directory.CreateDirectory(uploadPath);
        }
        file.SaveAs(Path.Combine(uploadPath, file.FileName));
        context.Response.Write(@context.Request["folder"] + file.FileName);
      }
      else
      {
        context.Response.Write("");
      }
    }
    else if (type == "del")
    {
      string picurl = context.Request["picurl"];
      try
      {
        File.Delete(context.Server.MapPath(picurl));
        context.Response.Write(picurl);
      }
      catch
      {
        context.Response.Write("");
      }
    }
    else
    { }
  }
  public bool IsReusable
  {
    get
    {
      return false;
    }
  }
}
이 기사의 사례를 읽으신 후 방법을 마스터하셨다고 믿습니다. 더 흥미로운 정보를 보려면 PHP 중국어 웹사이트의 다른 관련 기사를 주목하세요!

추천 자료:

jQuery EasyUI 플러그인을 사용하여 메뉴 링크 버튼을 만드는 방법

플로팅 링크 팝업 이미지 특수 효과 구현

위 내용은 Uploadify 플러그인은 진행률 표시줄을 사용하여 일괄 업로드 기능을 만듭니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.