Author Topic: get path from type input into toolbar  (Read 266 times)

erlind.dhami

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 3
    • View Profile
get path from type input into toolbar
« on: November 29, 2023, 10:11:11 pm »
I need get the path of file when i select a file excel (for example) from item type input into toolbar.
how can I do ? Can you help me? I use Version 8 Pro

This is code for item into toolbar:
Code: [Select]
        var elemtItem = {
            type: 'file',
            attrFile: "id='import_file' accept='.xls,.xlsx,.csv' title='Import Data from Csv or Xlsx'",
            icon: 'ui-icon-folder-open',
            style: 'margin-right:0;margin-left:1px;',
            listener: function (evt) {
                //import xlsx or csv file via HTML5 file input control.
                var grid = this,
                file = evt.target.files[0];//doesn't work in IE9.
                //var pippo = `${file.webkitRelativePath}`;
                //pippo = Server.MapPath("~");
                //console.log(pippo);
                if (file) {
                    console.log(file);
var tmppath = URL.createObjectURL(event.target.files[0]);
console.log(tmppath);
var filePath=$('#import_file').val();
console.log(filePath);
var path = (window.URL || window.webkitURL).createObjectURL(file);
console.log('path', path);
                    grid.showLoading();
                    //import first sheet of xlsx into workbook.
                    pq.excel.importXl({ file: file }, function (wb) {
                        //grid = grid.Tab().main();//always import in main tab.
                        //import workbook into grid.
                        console.log(wb);
                        //grid.importWb({ workbook: wb, extraRows: 0, extraCols: 0 });
                        grid.hideLoading();
                    })
                }
            }
        };

This is response:
Code: [Select]
File {name: 'CheckFornituraOpzioniRESNORES_more365gg_al20231129.xlsx', lastModified: 1701246539432, lastModifiedDate: Wed Nov 29 2023 09:28:59 GMT+0100 (Ora standard dell’Europa centrale), webkitRelativePath: '', size: 10380, …}lastModified: 1701246539432lastModifiedDate: Wed Nov 29 2023 09:28:59 GMT+0100 (Ora standard dell’Europa centrale) {}name: "CheckFornituraOpzioniRESNORES_more365gg_al20231129.xlsx"size: 10380type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"webkitRelativePath: ""[[Prototype]]: File
frmTestGrigliaShunt_retevera.html:124 blob:null/78241890-abd0-4664-8ca5-663ea8270ebe
frmTestGrigliaShunt_retevera.html:126 C:\fakepath\CheckFornituraOpzioniRESNORES_more365gg_al20231129.xlsx
frmTestGrigliaShunt_retevera.html:128 path blob:null/32652fb3-6c0f-45fc-821b-e2bdada8321a
frmTestGrigliaShunt_retevera.html:134 {sheets: Array(1), activeId: null}







paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: get path from type input into toolbar
« Reply #1 on: November 29, 2023, 11:25:10 pm »
You can only get the name of the file. Getting the path is not possible due to the security restrictions imposed by the browsers.