We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Empty posted file when using drag and drop

I'm using latest MVC version (17.2500.0.39) of the uploader following the image preview sample https://ej2.syncfusion.com/aspnetmvc/Uploader/ImagePreview#/material.

Posted file works when I use the browse button, however, when I use the drag and drop feature I can see the image preview but no file data is posted, all I get is an empty "application/octet-stream" when checking System.Web.HttpContext.Current.Request.Files["Avatar_File"].

This is my setup:

  Dictionary<string, object> htmlAttr = new Dictionary<string, object>();

  htmlAttr.Add("name", "Avatar_File");
  htmlAttr.Add("class", "form-control");

@Html.EJS().Uploader("uplAvatar").AutoUpload(false).Multiple(false).AllowedExtensions("image/*").Selected("OnFileSelect").HtmlAttributes(htmlAttr).Render()

I'm attaching the Javascript part for reference.

Attachment: uploader_1b52143b.zip

7 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team August 1, 2019 01:54 AM UTC

Hi Juan, 
Thanks for contacting Syncfusion support. 
We have checked the reported issue. We have prepared the image preview sample and it is working fine in drag and drop and manually upload the uploader. By using the shared code snippet, we have created sample. 
Also, we have taken video for drag and drop the files.  
 
If still you are facing problem kindly let us know with more details. So that we can provide prompt solution as earlier. 
 
Regards,  
Narayanasamy P.  



JJ Juan Jiminez August 1, 2019 01:51 PM UTC

Hi Narayanasamy,

Thanks for the sample. 

I forgot to mention I'm posting the uploaded file as part of a form with an ajax call, like:

var formdata = new FormData('myform').get(0));


            $.ajax({
                type: "POST",
                url: '/Save',
                data: formdata,
                dataType: 'json',
                processData: false,
                contentType: false,

                success: function (data) {                  
                                console.log(''saved'');                                  
                },
                error: function (xhr) {

                    console.log(''error'');       
                }

            });


NP Narayanasamy Panneer Selvam Syncfusion Team August 2, 2019 01:28 PM UTC

Hi Juan,  
Most welcome. 
We have checked the reported scenario. we have customFormData support in uploader, in that you can additional data to controller. So, we suggest you to use our customFormData for sending additional data to controller as mentioned below, 
function onUploading(args) {
args.customFormData = [{ 'File': args.fileData.name }];
}
 
 
Receives this file name in controller as mentioned below, 
var file = HttpContext.Request.Form["File"]; 
 
 
Regards, 
Narayanasamy P. 



JJ Juan Jiminez August 2, 2019 04:16 PM UTC

Hi Narayanasamy,

I don't need to pass in additional data, what I need is dropped files to be part of the form data on submission (not async upload), more like this sample is supposed to work https://ej2.syncfusion.com/aspnetmvc/documentation/uploader/form-support/.

Currently it does submit the file when I use the browse button but id doesn't work with drag and drop.

Best,


JS John Stemper August 2, 2019 09:13 PM UTC

Juan,
I have found the same issue and have started a thread about it here. The response from Syncfusion was that it was  reproduced and they are expecting a fix in SP1.


John


JJ Juan Jiminez replied to John Stemper August 3, 2019 01:00 AM UTC

Juan,
I have found the same issue and have started a thread about it here. The response from Syncfusion was that it was  reproduced and they are expecting a fix in SP1.


John

Thanks John, I appreciate it.


NP Narayanasamy Panneer Selvam Syncfusion Team August 5, 2019 09:13 AM UTC

Hi John / Juan, 

We appreciate your comments @John

As we promised earlier, we will include
remedy for this issue with upcoming Service-Pack1 release. Will intimate you once the SP1 release rolls out. We appreciate your patience until then.

 
Regards, 
Narayanasamy P. 


Loader.
Live Chat Icon For mobile
Up arrow icon