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

Setting hostUrl to a local file path

I followed the getting started document here and am left with the following:

     $(function () {
          var hostUrl = 'https://ej2services.syncfusion.com/production/web-services/';
          var filemanagerInstance = new ej.filemanager.FileManager({
               ajaxSettings: {
                    url: hostUrl + 'api/FileManager/FileOperations'
               }
          });
          filemanagerInstance.appendTo('#filemanager');
     });

This works fine, but I went to change to a network location as such:

     $(function () {
          var hostUrl = "z:\\folder1\\folder2\\folder3";
          var filemanagerInstance = new ej.filemanager.FileManager({
               ajaxSettings: {
                    url: hostUrl
               }
          });
          filemanagerInstance.appendTo('#filemanager');
     });

However, I get the following error:
     "NetworkError: Failed to send on XMLHTTPRequest: Failed to load z:\folder1\folder2\folder3"

I have tried setting hostUrl to a localhost url path, and tried adding file:/// to the front, but I always get this error.  Is there another way I'm supposed to use to access these folders?

1 Reply

KR Keerthana Rajendran Syncfusion Team November 7, 2019 10:20 AM UTC

Hi William,  
 
Greetings from Syncfusion support. 
 
We have checked your reported query “setting local path for file manager component”. We sorted out the issue, the path of the file manager is not set properly. In documentation, we are using online service link for file manager component. If you have to change the root path of the file manager component, we suggest you to use the local service for file manager component. The root path of the file manager component is set from 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. 
 
 
After running the local service, the service will be launched in the specific localhost URL. Refer that local host URL in the 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 file manager sample. 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Keerthana. 


Loader.
Live Chat Icon For mobile
Up arrow icon