Thursday 15 August 2013

c# - How to get base64 image from AjaxFileUpload? -



c# - How to get base64 image from AjaxFileUpload? -

i trying images set ajaxfileupload base64 strings. 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 files (in multi-upload) have completed.

there event fires 1 time each file uploaded, called uploadcomplete. should handle 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 together 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 name of file fileuploader.saveas(mappath("path/where/you/want/to/save/file")); // 1 time saved, can farther manipulate file if wish } }

c# jquery asp.net ajax ajaxcontroltoolkit

No comments:

Post a Comment