Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Sending parameters with fileUpload
posted

Im having a bit of a problem when two or more users are uploading files at the same time. The uploads seems to be mixed up on the server.

Im trying to do this by reading the UrlReferer for each incoming request.

internal static void HandlerUploadFinising(object sender, UploadFinishingEventArgs args) {

   var uploadId = Convert.ToInt32(System.Web.HttpContext.Current.Request.UrlReferrer.Segments.Last());

}

internal static void HandlerUploadFinished(object sender, UploadFinishingEventArgs args) {

   var uploadId = Convert.ToInt32(System.Web.HttpContext.Current.Request.UrlReferrer.Segments.Last());

}

This does not work when two users are uploading at the same time.

Is there any way of sending parameters to the server for each upload. I need to send a unique user id from the the client to the server to ensure that the upload is saved to the correct user.

Parents
No Data
Reply
  • 2355
    Suggested Answer
    Offline posted

    Hi, 

    Thank you for posting in Infragistics forums! Last Service Release we added a new functionality that helps you implement this scenario very easy. The first thing is to handle onFormDataSubmit event and then call addDataField method to add the information you want to send to the server. The code looks like something like this:    

    $("#upload1").on("iguploadonformdatasubmit", function (evt, ui) {
        $("#upload1").igUpload("addDataField", ui.formData, { "name": "Parameter Name", "value": "Value" });
    });
    

    The second thing is to get the sent information on the server side. Every server side event argument has an extra property called AdditionalDataFields which holds the information in “Name-Value” format. The code looks like this:

    public static void igUpload_UploadStarting(object sender,
    Infragistics.Web.Mvc.UploadStartingEventArgs e){ foreach (var dataField in e.AdditionalDataFields) { string fieldName = dataField.Name; string fieldValue = dataField.Value; } }

    I hope this helps!  

    Kind regards,
    Petko Zhekov
    Software Developer

Children