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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

File upload and Save it into local folder

Thread ID:

Created:

Updated:

Platform:

Replies:

149182 Nov 18,2019 06:45 AM UTC Nov 20,2019 01:35 PM UTC Angular - EJ 2 3
loading
Tags: Uploader
Swathi
Asked On November 18, 2019 06:45 AM UTC

Hi,

Need help on File upload and Save the uploaded file in  local folder in My computer. After saving when user clicks on "Get  Files" button, need to fetch all files from stored location and display on the screen.

Attachment: Fileupload_task_d9aedd8.zip

Sureshkumar P [Syncfusion]
Replied On November 19, 2019 12:12 PM UTC

Hi Swathi, 
 
Greetings from Syncfusion support. 
 
We have validated your requirement. We can get the saved files details by using GetFiles method in C#,  that will return the names of files (including their paths) in the specified directory. 
 
Kindly refer to the below code block. 
 
[app.component.html] 
 
<button id='btn' (click)="getFiles()">getFiles</button> 
 
[app.component.ts] 
 
getFiles() { 
     $.ajax({ 
      type: "POST", 
      url: 'http://localhost:61046/Home/GetFilesDetails', 
      success: function (data) { 
        for (let i: number = 0; i < data.length; i++) { 
          let filesData = data[i].split('\\'); 
          let length = filesData.length 
          console.log(filesData[length - 1]); 
        } 
        return data; 
      }, 
      error: function () { 
        alert('Error occured'); 
      } 
    }); 
  } 
 
[controller] 
 
        [AcceptVerbs("Post")] 
        public string[] GetFilesDetails() 
        { 
            string path = hostingEnv.WebRootPath; // your saved files local path 
            return Directory.GetFiles(path); 
        } 
 
To know more about getFiles C# method. Please refer to the below documentation link: https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=netframework-4.8  
 
Regards, 
Sureshkumar P 


Swathi
Replied On November 19, 2019 12:20 PM UTC

Hi,

Thanks for response, my question is in Angular how to upload and save files in local folder.(Example in C://Documents).
After that display the uploded files on the screen.

Sureshkumar P [Syncfusion]
Replied On November 20, 2019 01:35 PM UTC

Hi Swathi, 
 
We have created a sample based on your requirement. Please find the sample here 
 
 
 
Also, we have created a video presentation for your reference. Please find the video presentation here: https://www.syncfusion.com/downloads/support/forum/149182/ze/ScreenCapture_11-20-2019_5.26.44_PM.xesc-1645996350  
 
Regards, 
Sureshkumar P  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon