2009-11-07 20:38  曾祥展  阅读(4366)  评论(32编辑  收藏

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

using Subgurim.Controles;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// IsPosting可以标识是否触发上传事件.只有这种情况下才会触发保存文件事件,否则不会影响原页面的加载 .
{
}
}

private void managePost()
{

if (pf.Type == HttpPostedFileAJAX.fileType.image)
{
}

}
}


<%@ Register Assembly="FUA" Namespace="Subgurim.Controles" TagPrefix="cc1" %>

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

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

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.

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

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.

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

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