how to replace retired flashupload functionality with fileupload for single image in asp.net?

Omble, Omkar [JANIE NON-J&J] 0 Reputation points
2023-01-30T11:35:16.76+00:00

how to replace retired flashupload functionality used for uploading multiple images with fileupload for uploading single image in asp.net? Since flashplayer has reached end of support, I need to replace with existing alternative of fileupload control by using upload http handler. Please suggest?

Developer technologies .NET Other
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
    2023-01-31T03:21:37.03+00:00

    Hi @Omble, Omkar [JANIE NON-J&J],

    You can refer to this link to implement uploading files using httphandler.

    In the ProcessRequest method, loop through the Request.Files array and save them to a local folder using the FileSaveAs method of the HttpPostedFile class.

    public void ProcessRequest(HttpContext context)
    {
        string filePath = "FileSave//";
    
        //write your handler implementation here.
        if (context.Request.Files.Count <= 0)
        {
            context.Response.Write("No file uploaded");
        }
        else
        {
            for (int i = 0; i < context.Request.Files.Count; ++i)
            {
                HttpPostedFile file = context.Request.Files[i];
                file.SaveAs(context.Server.MapPath(filePath+file.FileName));
                context.Response.Write("File uploaded");
            }
        }
    }
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Albert Kallal 5,586 Reputation points
    2023-01-31T17:52:42.4+00:00

    I think uploaders can be quite a bit of work.

    I would suggest adopting a "existing" nice downloader.

    There are number of good ones - even free. I not used "filepond", but it looks real nice an modern.

    And for webforms, I been using the ajaxtoolkit one. (to be fair adopting the "whole" ajaxtoolkit for just a up-loader is a bit much, but there there also some great phone number input controls, pop dialogs, and a html editor. (all of which I use, so the decision to use the ajaxfile uploader also included was a easy choice for me.

    So, the uploader looks like this in operation:

    uploadex

    so, there are lots of good replacements, and filepond or the above ajaxfile up-loader is free.

    You can find the free ajaxtoolkit here:

    https://www.devexpress.com/Products/AJAX-Control-Toolkit/

    So, you could as noted, roll your own, but I would consider the above examples. I am sure there are many more, but I had great success with the above free ajaxtoolkit, and the ajaxfileuploader control.

    The markup for above is not much either. I just dropped in the file up-load control, a radito button, and a gridview.

    So, this:

                    <div id="uploadfiles" runat="server" style="width:800px">
                        <ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
                            OnUploadComplete="AjaxFileUpload1_UploadComplete" 
                            OnClientUploadCompleteAll="AllDone" />
                    </div>
    
    

    and below above, I did add a gridview.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.