I am trying to get the images put into an AjaxFileUpload as base64 strings. Would I do this in 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>
The UploadCompleteAll
event fires when all files (in a multi-upload) have completed.
There is also another event that fires once for each file uploaded, called UploadComplete
. You should handle that event.
// 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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.