• SlickUpload Upload to disk


    The file upload stream provider is a built-in SlickUpload provider that uses the filesystem for uploaded file storage. Using this provider, SlickUpload can store files to any location your ASP.NET application has access to, including paths inside the application, other paths on the same server, or a seperate server via a UNC path to a file share.

    Configuration

    To use the file provider, set the type="File" attribute on the uploadStreamProvider web.config key. The following settings allow you to customize the filename and location where the files will be stored:

    1
    <uploadStreamProvider type="File" />

    If you want more control over the storage location, you can inherit from theFileUploadStreamProvider class to create your own custom file based upload stream provider.

    Attributes

    location – Optional String attribute
    Specifies the root storage location. This can be an absolute path (c:folder), an app relative path (~/folder), or a UNC path (\serverfolder).

    NOTE: The user ASP.NET is running under (by default ASPNET for XP and IIS_WPG for Windows 2003 and later) must have write access to the specified path.

    existingAction – Optional ExistingAction attribute
    Specifies the action to take when trying to upload to a file that exists.
    Exception
    Throw an exception and cancel the upload.
    Overwrite
    Overwrite the existing file
    Rename
    Rename the new file using a rename sequence to find the first unused filename. The builtin sequence starts with the desired filename, then iterates a number N starting with 1 and appends [N] to the filename until it finds a free filename.

    You can customize the rename sequence by creating a class that inherits fromFileUploadStreamProvider and overriding the GetRenameSequence method, returning a new sequence generator for your desired renaming sequence.

    Default: Exception
    fileNameMethod – Optional FileNameMethod attribute
    Specifies the method to use to generate a filename. Possible values:
    Client
    Use the client filename as the server filename.
    Guid
    Use a unique GUID as the server filename.
    Default: Client

    Controlling the filename during upload

    To control the filename used during the upload, you can use one of the three file name generation methods defined above: Client or Guid.

    If you want to generate your own filename (including path if you desire), you can create a class that inherits from FileUploadStreamProvider and override the GetServerFileNamemethod. For an example of this, look at the CustomFileName sample. You can also override other methods of the FileUploadStreamProvider class to do more customization, such as a custom rename sequence.

    Retrieving the server filename

    After the upload you can get the server filename a file was written using theUploadedFile.ServerLocation property.

  • 相关阅读:
    rdlc报表动态生成实例
    动态分页实现
    多文件上传
    文件压缩
    javascript解决中文传递乱码和特殊字符问题
    rdlc报表动态生成公共类
    SQLHelp类
    验证码
    使用bison和yacc制作脚本语言(3)
    C Mingw gcc printf 刷新缓冲行
  • 原文地址:https://www.cnblogs.com/8090sns/p/3311381.html
Copyright © 2020-2023  润新知