zoukankan      html  css  js  c++  java
  • FileUploadAJAX无刷新上传

    http://en.fileuploadajax.subgurim.net/

      此控件支持如下功能:
    1:多文件上传.
    2:可以配置最大上传文件个数.
    3.自定义js脚本.
    4.支持删除已经上传的文件.
    5.支持无刷新上传效果(iframe)
    6.可配置相关提示文本

    此控件是基于iframe方式实现的无刷新,开发人员并不需要开发iframe中的内容页,控件采用当前页来充当iframe的内容页.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    using Subgurim.Controles;
      
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // IsPosting可以标识是否触发上传事件.只有这种情况下才会触发保存文件事件,否则不会影响原页面的加载 .
            if (FileUploaderAJAX1.IsPosting)
            {
                this.managePost();  //一定要放在Page_Load事件中
            }   
        }
      
        private void managePost()
        {
      
            HttpPostedFileAJAX pf = FileUploaderAJAX1.PostedFile;
            if (pf.Type == HttpPostedFileAJAX.fileType.image)
            {
                FileUploaderAJAX1.SaveAs(Page.ResolveUrl("~/123/"), pf.FileName);
            }
            FileUploaderAJAX1.PostedFile.responseMessage_Uploaded_NotSaved = "<span style=\"font-family: arial; font-size: 12px;\">Sorry, there was a problem uploading this file.</span>";
      
        }
    }

    1

    注册 引用

    1
    2
    3
    4
    5
    6
    7
    <%@ Register Assembly="FUA" Namespace="Subgurim.Controles" TagPrefix="cc1" %> 
      
    <cc1:FileUploaderAJAX ID="FileUploaderAJAX1" runat="server" /> 
      
    C#: using Subgurim.Controles;
      
    VB.NET: Imports Subgurim.Controles

    参数:

    FileName:
    Name of the original file, as it is listed on the computer.

    FileName_SavedAs:
    Path (Directory + Name) that we have given to the file upon storing it to the system (applicable only when having done a Save).

    FileName_Path:
    Path formatted so that it is accessible by normal HTML.

    ContentType:
    The MIME type of the content of the file. Useful to filter what types of files we are going to admit. All of the examples are filtered to only

    accept GIF images whose ContentType is "image/gif".

    Type:
    Is an enumerator "FileType" that assists ContentType to ascertain the type of file being dealt with. Basing on the ContentType (never the

    extension of the file), allows us to distinguish the following types of files:

    image: a file of any image: .gif, .jpg, .png, .bmp, etc.
    audio: a file of any audio: .mp3, .wav, etc.
    video: a file of general video: .mpg, .avi, etc.
    text: a file that can be read like text. Can be flat text, an HTML file, a CSS file, an XML file, etc.
    office: files used in the Office series of programs. (Word, Excel, PowerPoint, Access, Publisher, Project, etc.).
    zip: ZIP compressed files.
    application: Executable files that are not Office or ZIP files.
    others: If the ContentType is known, but the file doesn’t match any other listed Type.
    unknown: When the ContentType is not known.

    ContentLength:
    Length (in bytes) of the file. Also useful to limit maximum file size. All of the examples on this website prohibit files larger than 5KB

    responseMessage_Uploaded_Saved:
    Message that is displayed on screen when a file was successfully saved.

    Defaults to:
    "<a href="{3}" target="_blank">{0}</a> (>i>{1}>/i>) {2}KB".
    Where:
    {0} = FileName
    {1} = ContentType
    {2} = ContentLength
    {3} = path for FileName_SavedAs

    responseMessage_Uploaded_NotSaved:
    Message that is displayed on screen when a file has not been properly stored.
    Defaults to: "{0} is not saved." Where {0} = FileName

    Saved: Boolean indicating whether the file has been stored correctly or not.
    Deleted: Boolean indicating whether the file was deleted after you have uploaded.

    responseMessage_Uploaded:
    If there have been no changes, this is the message that the user sees after uploading the file. If the file was saved successfully display

    “responseMessage_Uploaded_Saved”, otherwise “responseMessage_Uploaded_NotSaved”.

    IsRequesting: indicates if a request due to FileUpload AJAX has been initiated. The request can be initiated when a file is uploading or

    when it is being erased.

    IsPosting: indicates that a file from the FileUpload AJAX control is uploading.

    IsDeleting: indicates that a file is being deleted by FileUpload AJAX.

    PostedFile: provides access to the HttpPostedFileAJAX that FileUpload AJAX uploaded.

    Saving the PostedFile: we have 3 options when we have uploaded the PostedFile, none of which involve using "server.MapPath(...)",

    because the control does it automatically:

    SaveAs(string path): save the file to the specified path (directory + file name). The results are identical to the SaveAs command in the

    standard FileUpload control.

    Save(): save the file in the root of our application with the original name.

    SaveAs(string directoryPath, string FileName): save the file in the specified directory (directoryPath) and with the specified name

    (FileName). A function that is missing from the standard FileUpload control.

  • 相关阅读:
    Atitit 编程语言编程方法的进化演进 sp  COP ,AOP ,SOP
    Atitit 2016年attilax事业成就表
    Atitit 知识管理的重要方法 数据来源,聚合,分类,备份,发布 搜索
    Atitit webservice发现机制 WS-Discovery标准的规范attilax总结
    Atitit 多元化战略 适合我们发展 的核心业务attilax总结
    Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
    Atitit. 提升存储过程与编程语言的可读性解决方案v3 qc25.docx
    Atitit zxing二维码qr码识别解析
    Atitit Data Matrix dm码的原理与特点
    Atitit 常用二维码对比(QR、PDF417、DM、汉信码 Aztec code maxicode
  • 原文地址:https://www.cnblogs.com/rhinemetal/p/2569543.html
Copyright © 2011-2022 走看看