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.

  • 相关阅读:
    php之static静态变量详解
    设计模式【代理模式】
    小牟Andorid下面MD5具体实现的思路总结
    ubuntu14.04安装MySQL
    Android手机定位技术的发展
    我不同意你,这是您的支持
    我要遵守11文章数据库设计指南
    quick-cocos2d-x游戏开发【3】——display.newSprite创建向导
    第二章 自己的框架WMTS服务,下载数据集成的文章1
    JSTL实现int数据的类型的长度
  • 原文地址:https://www.cnblogs.com/8090sns/p/3311381.html
Copyright © 2011-2022 走看看