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

Setting path setting to a local location

Thread ID:

Created:

Updated:

Platform:

Replies:

148919 Nov 7,2019 07:37 PM UTC Nov 14,2019 06:25 AM UTC JavaScript - EJ 2 8
loading
Tags: FileManager
William
Asked On November 7, 2019 07:37 PM UTC

I have the following:

     var hostUrl = 'https://ej2services.syncfusion.com/production/web-services/';
     var filemanagerInstance = new ej.filemanager.FileManager({
          ajaxSettings: {
               url: hostUrl + 'api/FileManager/FileOperations'
          },
          view: "Details",
          allowDragAndDrop: true,
          path: "z:\\myfolder1\\myfolder2\\myfinalfolder"
     });

However, it seems it's still using the default folder path (D:\home\site\production\web-services-1-10-19\wwwroot\Files) and adding path to the end of it, causing the following error:
     The given path's format is not supported.

How do I completely negate the default folder path, and just use my own local file path?

Keerthana Rajendran [Syncfusion]
Replied On November 8, 2019 09:13 AM UTC

Hi William,  
 
Good day to you. 
 
We have checked your reported query that setting local path for file manager component. We sorted out the issue, the path of the file manager is not properly initialized. In our documentation, we are using the online service link for file manager component. If you want to change the root path of the file manager component, we suggestd you to use the local service for file manager component. The root path of the file manager component is set by the server side. 
 
Refer the below code snippet to set the root path. File location  
 
Controller/FileManagerController.cs 
        public PhysicalFileProvider operation; 
        public string basePath; 
        string root = "D:\\support\\controller"; 
        public FileManagerController(IHostingEnvironment hostingEnvironment) 
        { 
            // Map the path of the files to be accessed with the host 
            this.basePath = hostingEnvironment.ContentRootPath; 
            this.operation = new PhysicalFileProvider(); 
            // Assign the mapped path as root folder 
            this.operation.RootFolder(this.root); 
        } 
       
 
For your reference, we have attached a local service for file manager component. In that service, you have to change the root path of file manager component. 
 
 
Download the attached sample and run the service. After running the local service, the service is launched in the specific localhost URL. Refer that local host URL in your file manager sample.  
 
Refer the below code snippet for specifying the local host URL. 
 
var hostUrl = 'http://localhost:62869/'; 
    var fileObject = new ej.filemanager.FileManager({ 
            ajaxSettings: { 
                url: hostUrl + 'api/FileManager/FileOperations', 
                getImageUrl: hostUrl + 'api/FileManager/GetImage', 
                uploadUrl: hostUrl + 'api/FileManager/Upload', 
                downloadUrl: hostUrl + 'api/FileManager/Download'     
            }, 
      view: 'Details' 
    }); 
    fileObject.appendTo('#filemanager'); 
 
For your reference, we have prepared a sample. After running the file manager local service, refer the service URL in below file manager sample. 
 
 
 
In your sample, you have using path API. The current path of the File Manager can be specified initially or dynamically using the path property.  If you want to initialize the file manager component in specific folder location, you case use the path property. 
 
 
Please let us know, if you have any concerns. 
 
Regards, 
Keerthana.

William
Replied On November 8, 2019 05:38 PM UTC

Thanks for the reply, Keerthana.  Where do I find the local service and is there a getting started page for that?

Keerthana Rajendran [Syncfusion]
Replied On November 11, 2019 11:15 AM UTC

Hi William,   
 
We have checked your reported query for documentation link for file manager component using local service. Refer the below documentation link for local file manager service. 
 
 
Please let us know, if you have any concerns. 
 
Regards, 
Keerthana

William
Replied On November 12, 2019 09:38 PM UTC

Hi Keerthana,

I did as the tutorial says and ended up with:

     var hostUrl = 'http://localhost:12345/';
     var filemanagerInstance = new ej.filemanager.FileManager({
          ajaxSettings: {
               url: hostUrl + 'api/FileManager/FileOperations',
               getImageUrl: hostUrl + 'api/FileManager/GetImage',
               uploadUrl: hostUrl + 'api/FileManager/Upload',
               downloadUrl: hostUrl + 'api/FileManager/Download'
          },
          view: "Details",
          allowDragAndDrop: true
     });

However, I get the following error: 

     NetworkError: Failed to send on XMLHTTPRequest: Failed to load http://localhost:12345/api/FileManager/FileOperations

I tried removing the api/ from api/FileManager/FileOperations like it has in the tutorial but I still get the same error.

Thanks,
William

P.S.  I use MVC5, not core

William
Replied On November 12, 2019 10:31 PM UTC

I found out localhost:12345 is being blocked by CORS policy.  Is there anyway I could download localhost:12345/FileManager/FileOperations and the rest so I don't have to reference them by the localhost:12345 url?

Keerthana Rajendran [Syncfusion]
Replied On November 13, 2019 11:58 AM UTC

Hi William, 
 
 
Sorry for the inconvenience. 
 
 
We have checked your reported error. By default, the reported error occurs when the browser blocks the request from different domains. In that case, we suggest you to enable the access-control-allow-origin in file manager service server side.  
 
 
Refer the below code snippet in Web.config file. In this code, enable the CORS in your file manager service. 
 
<system.webServer> 
    <httpProtocol> 
      <customHeaders> 
        <add name="Access-Control-Allow-Origin" value="*" /> 
        <add name="Access-Control-Allow-Headers" value="Content-Type" /> 
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> 
      </customHeaders> 
    </httpProtocol> 
</system.webServer> 
 
After adding this code in your local service. Run the service and refer the local host URL in below file manager sample. 
 
 
 
We will add these changes in our documentation and refresh it in our upcoming release. 
 
 
Please let us know, if you have any concerns. 
 
 
Regards, 
Keerthana. 


William
Replied On November 13, 2019 10:48 PM UTC

Thank you so much for helping through this process.  Everything seems to be working now.

Keerthana Rajendran [Syncfusion]
Replied On November 14, 2019 06:25 AM UTC

Hi William,  
 
Most welcome. We are glad to hear that the issue has been resolved.  Please get back to us if you need further assistance on this. 
 
Regards, 
Keerthana. 


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