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.

  • 相关阅读:
    control与delegate的Invode、BeginInvoke (一) jason
    你是否愿意每周最少工作80小时 (转)
    详解ASP.NET的SEO:服务器控件背后故事
    深度解析Windows Phone 7开发
    .NET 4新特性:表、SEO及可扩展输出缓存
    VS2010中Parallel类实现并行计算
    iPhone破解软件定制版blackra1n 提供下载
    .NET 4中废弃的特性
    Windows Server 2008 R2上安装WSUS 3.0 SP2
    关于浮动
  • 原文地址:https://www.cnblogs.com/8090sns/p/3311381.html
Copyright © 2011-2022 走看看