Programmatic File Upload

Hello,  

Is there a way to use the SfFileUpload to achieve a programmatic file upload?

I see that the API provides the following methods:
  • CreateFileList
  • Upload
Can these be used to perform a programmatic upload if the file blob URL and name are known? If so could you please advise how the parameters are to be formed?

Thanks

1 Reply 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team June 11, 2020 12:21 PM UTC

Hi Pranshu, 


Greetings from Syncfusion support. 


You can use the public upload to upload the file programmatically. Please refer to the code below, 


<div class="form-group"> 
        <SfUploader @ref="UploadObj" ID="UploadFiles" Multiple="false" AutoUpload="false"> 
        </SfUploader> 
    </div> 
    <button type="submit" class="btn btn-primary" @onclick="@onClick">Upload</button> 
 
@code{ 
    SfUploader UploadObj; 
 
    public async Task onClick() 
    { 
        await this.UploadObj.Upload(); 
    } 
     
} 


You can use the UploaderUploadedFiles tag to manually create a list of files. 

<SfUploader @ref="UploadObj" ID="UploadFiles" Multiple="false" AutoUpload="false"> 
            <UploaderEvents ValueChange="OnChangeUpload"></UploaderEvents> 
            <UploaderUploadedFiles Name="Nature" Size=500000 Type=".png"></UploaderUploadedFiles> 
            <UploaderUploadedFiles Name="TypeScript Succinctly" Size=12000 Type=".pdf"></UploaderUploadedFiles> 
            <UploaderUploadedFiles Name="ASP.NET Webhooks" Size="500000" Type=".docx"></UploaderUploadedFiles> 
        </SfUploader> 




Regards, 
Sevvandhi N 


Marked as answer
Loader.
Up arrow icon