I wanted to use uploadbox to get some object back from api call.

Hi Team,

 I am Divakaran . We are cuurently using EJ1 syncfusion Product.

Query:

1,  My Project is developing based on Angular 4 and Typescript .  

2, Business Logics are done ( Saving , reterieving , deleting on Database ) by using Asp.net core Web Api.

3, In My application , i want to use multiple upload . But i don't know how to proceed .

4, Please help me on this .




Thanks ,

Divakaran N

1 Reply

PO Prince Oliver Syncfusion Team July 12, 2018 07:06 AM UTC

Hi Divakaran,   
  
Thank you for contacting Syncfusion Support.   
  
To use our components in Angular 4 project, kindly refer to the following Getting Started section of the UG documentation: https://help.syncfusion.com/angular/gettingstarted/overview     
  
Once the project is set up to run our components, add the following code to render the Upload box.   
  
[HTML] 
<ej-uploadbox id="UploadDefault" [saveUrl]="saveURL" [multipleFilesSelection]="true" ></ej-uploadbox> 
 
 
[TS] 
saveURL:string; 
constructor() { 
  this.saveURL = 'UploadFiles'; 
} 
 
  
For further information, please refer to the following Getting Started section for Uploadbox: https://help.syncfusion.com/angular/uploadbox/getting-started      
  
In the above code, setting multipleFilesSelection to true, allows selecting and uploading multiple files. We have used the saveUrl property to map the save handler in the controller. Kindly refer to the following Save handler code.   
  
[c#] 
[HttpPost] 
public IActionResult UploadFiles(IList<IFormFile> UploadDefault) 
{ 
    long size = 0; 
    foreach (var file in UploadDefault) 
    { 
        var filename = ContentDispositionHeaderValue 
                        .Parse(file.ContentDisposition) 
                        .FileName 
                        .Trim().ToString(); 
        filename = hostingEnv.WebRootPath + $@"\{filename}"; 
        size += file.Length; 
        using (FileStream fs = System.IO.File.Create(filename)) 
        { 
            file.CopyTo(fs); 
            fs.Flush(); 
        } 
    } 
    return Content(""); 
} 
  
We have attached a sample for your convenience, kindly refer to the attached sample and let us know if you require further assistance.   
  
  
Regards,   
Prince   


Loader.
Up arrow icon