zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    centos/7/isos/x86_64 下载
    Zend Guard Run-time support missing 问题的解决
    php.ini
    PS 基础知识 .pat文件如何使用
    PS 基础知识 .atn文件如何使用
    PS 如何用制作键盘图标
    PS 如何制作WIN7的玻璃化透明窗口效果
    PS常用平面设计制作尺寸
    如何使用Medieval CUE Splitter分割ape,合并ape,制作cue
    如何将MID音乐转换成MP3
  • 原文地址:https://www.cnblogs.com/8090sns/p/3311381.html
Copyright © 2011-2022 走看看