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

How to pass additional parameters at File Upload

How can I pass additional parameters together with the file upload and then access them in the controller.

12 Replies

BC Berly Christopher Syncfusion Team July 15, 2019 06:05 AM UTC

Hi Mikael,   
  
 
Sorry for the inconvenience.  
  
 
This was a known issue in our File uploader component. We are currently working on it and will include the fix in our upcoming release, which is expected to be rolled out by end of July 2019.   
  
 
Please find the feedback portal link to track this defect status.    
 
 
  
We appreciate your patience until then. 

Regards, 
Berly B.C


J j March 27, 2020 03:28 AM UTC

Hi Syncfusion,

   I cannot download the given sample from here
permission denied.

The file I'm trying to download is
https://www.syncfusion.com/downloads/support/directtrac/238212/ze/BlazorApp1-1587018225

Can you please allow me to download it?




J j March 27, 2020 03:40 AM UTC

Actually what I'm trying to do is how can I retrieve the custom headers (which is essentially param) in the Controller:

public async Task Save(IList<IFormFile> uploadFiles) { ... }


BC Berly Christopher Syncfusion Team March 27, 2020 10:04 AM UTC

Hi Mikael, 

Sorry for the inconvenience caused. 

Now the feedback link is accessible and we are glad to announce that our latest release in the version 17.2.0.47-beta has been rolled out successfully and, in that release,, we have included the “The custom header not able to add in uploading file request”. You can use FileSelected event and set your header in CurrentRequest argument (args.CurrentRequest) based on key-value pair.  
 
NuGet: 
 
Scripts
 

We have prepared sample and code snippet for your reference.     

 
@using Syncfusion.EJ2.Blazor 
@using Syncfusion.EJ2.Blazor.Inputs 
<h4Upload custom header </h4> 
<EjsUploader> 
    <UploaderEvents FileSelected="OnFileSelect"></UploaderEvents> 
    <UploaderAsyncSettingsSaveUrl ="https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save" RemoveUrl="https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove"> </UploaderAsyncSettings> 
</EjsUploader> 
@code{ 
    public void OnFileSelect(SelectedEventArgs args) 
    { 
        args.CurrentRequest = new List<object> { new { custom - header = "Syncfusion" } }; 
    } 
} 
 
 

Regards, 
Berly B.C


CH Christian April 14, 2020 01:01 AM UTC

Hello Syncfusion,
I'm also looking into how I can send along a parameter/identifier with the file upload.  Is it currently in version 18.1.0.43?



BC Berly Christopher Syncfusion Team April 14, 2020 10:19 AM UTC

Hi Christian, 
  
Yes, we have the support for sending custom form data for the Uploader in the latest version on selected event. We have prepared the sample and attached it below.  
  
@using Syncfusion.Blazor.Inputs 
<SfUploader ID="UploadFiles"> 
    <UploaderEvents FileSelected="onFileSelect"></UploaderEvents> 
    <UploaderAsyncSettings SaveUrl="api/SampleData/Save"> 
    </UploaderAsyncSettings> 
</SfUploader> 
 
@code { 
 
    private void onFileSelect(SelectedEventArgs args) 
    { 
        args.CustomFormData = new List<object> { new { Name = "Syncfusion" } }; 
    } 
 
 

  
  
Please find the below documentation to know more about Uploader component. 
  
  
  
Regards, 
Berly B.C 



IG Irakli Gabadze June 15, 2020 11:58 AM UTC

There is no need of some extra js work. just look at my images. You can pass and get custom parameters very easily in this way.

Attachment: images_5468b3d6.zip


BC Berly Christopher Syncfusion Team June 16, 2020 10:56 AM UTC

Hi Irakli,   
  
Thanks for the suggestion and it is working for us.   
  
Regards,  
Berly B.C 



MA Mr Andrey Voronov April 12, 2021 12:38 PM UTC

what if header name is a variable:

var headername = "Custom.Header"

this does not work:

args.CurrentRequest = new List<object> { new object[] { headername, "Syncfusion" } }; 


BC Berly Christopher Syncfusion Team April 13, 2021 10:48 AM UTC

Hi Mikael, 

We have checked the provided code snippet and you have defined the headername as a string variable. So, the provided value is just append to the response header. So, we suggest you to assign the value properly as mentioned below code example to get rid of the reported issue. 

@code { 
    public class Custom 
    { 
        public string Header { get; set; } = "header"; 
    } 
    public Custom custom = new Custom(); 
    private void onFileSelect(SelectedEventArgs args) 
    { 
        var headername = custom.Header; 
 
        args.CurrentRequest = new List<object> { new object[] { headername, "Syncfusion" } }; 
    } 
    } 

Screenshot: 
 
 


Regards, 
Berly B.C


SA Scott A Shaw replied to Irakli Gabadze July 18, 2023 05:54 PM UTC

Awesome, I've spend ages looking at this and this worked perfectly!



YS Yohapuja Selvakumaran Syncfusion Team July 19, 2023 03:30 PM UTC

Hi Scott A Shaw,

 We are delighted to hear that your needs have been fulfilled. We look forward to serving you in the future.


Regards,

Yohapuja S


Loader.
Up arrow icon