I am trying to get the images put into an AjaxFileUpload as base64 strings. Would I do this in OnUploadCompleteAll?
我试图将图像作为base64字符串放入AjaxFileUpload。我会在OnUploadCompleteAll中执行此操作吗?
protected void AjaxFileUpload1_UploadCompleteAll(object sender, AjaxFileUploadCompleteAllEventArgs e)
{
}
In aspx:
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" AllowedFileTypes="jpg,jpeg,png,gif" MaximumNumberOfFiles="5" OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"></asp:AjaxFileUpload>
1 个解决方案
#1
0
The UploadCompleteAll
event fires when all files (in a multi-upload) have completed.
当所有文件(在多上传中)完成时,将触发UploadCompleteAll事件。
There is also another event that fires once for each file uploaded, called UploadComplete
. You should handle that event.
还有一个事件会为每个上传的文件触发一次,称为UploadComplete。你应该处理那个事件。
// in ASPX page
<asp:AjaxFileUpload ID="AjaxFileUpload1"
runat="server"
AllowedFileTypes="jpg,jpeg,png,gif"
MaximumNumberOfFiles="5"
OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"
OnUploadComplete="AjaxFileUpload1_UploadComplete">
</asp:AjaxFileUpload>
And in code behind add something like this:
在后面的代码中添加如下内容:
// in code-behind
protected void AjaxFileUpload1__OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
if (e.ContentType.Contains("jpg") || file.ContentType.Contains("jpeg")
|| file.ContentType.Contains("png") || file.ContentType.Contains("gif"))
{
// file.FileName contains the name of the file
fileUploader.SaveAs(MapPath("path/where/you/want/to/save/file"));
// once saved, you can further manipulate the file if you wish
}
}
#1
0
The UploadCompleteAll
event fires when all files (in a multi-upload) have completed.
当所有文件(在多上传中)完成时,将触发UploadCompleteAll事件。
There is also another event that fires once for each file uploaded, called UploadComplete
. You should handle that event.
还有一个事件会为每个上传的文件触发一次,称为UploadComplete。你应该处理那个事件。
// in ASPX page
<asp:AjaxFileUpload ID="AjaxFileUpload1"
runat="server"
AllowedFileTypes="jpg,jpeg,png,gif"
MaximumNumberOfFiles="5"
OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"
OnUploadComplete="AjaxFileUpload1_UploadComplete">
</asp:AjaxFileUpload>
And in code behind add something like this:
在后面的代码中添加如下内容:
// in code-behind
protected void AjaxFileUpload1__OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
if (e.ContentType.Contains("jpg") || file.ContentType.Contains("jpeg")
|| file.ContentType.Contains("png") || file.ContentType.Contains("gif"))
{
// file.FileName contains the name of the file
fileUploader.SaveAs(MapPath("path/where/you/want/to/save/file"));
// once saved, you can further manipulate the file if you wish
}
}