JavaScript / HTML Help

Kachaya

Well-known member
  • Jul 11, 2012
    1,427
    676
    113
    ගයිස් මට පොඩි වැඩකට ඕන වෙලා තියනවා CSV ෆයිල් එකක් HTML වලින් ඕපන් කරගන්න. ටේබල් එකක් විදියට. ජාලේ කරක් ගහල සාම්පල් කෝඩ් එකක් හොයාගත්ත. ඒත් එකේ තියෙන්නේ ෆයිල් පිකර් එකකින් ෆයිල් එක සිලෙක්ට් කරලා ටේබල් එක ගහගන්න. එත් මට ඕන ෆයිල් පිකර් එක අයින් කරලා ෆයිල් එක ඔපෙන් කරද්දීම ඩිරෙක්ට් මගේ එක HTML ටේබල් එකකට කන්වට් කරගන්න. කොහොමද මේ කෝඩ් එක එඩිට් කරන්න ඕන. JS වැඩ්ඩෝ සපෝට් එකක් දීපල්ලකෝ කොල්ලනේ

    1644697772047.png

    1644697799681.png
     

    Kachaya

    Well-known member
  • Jul 11, 2012
    1,427
    676
    113
    CSV file eka remote host karala try karala balanna.
    1644729258027.png

    machan mata ona me file picker eka ain karala. csv file eke location eka hard code karagnna.

    The question is how do you select a file if you remove the INPUT element?
    1644729337675.png

    machan mata ona me file picker eka ain karala. csv file eke location eka hard code karagnna.
    ------ Post added on Feb 13, 2022 at 10:45 AM
     

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,714
    12,619
    113
    127.0.0.1:8080/Kandy

    kolavari

    Well-known member
  • Aug 11, 2012
    33,746
    1
    25,653
    113
    කැළෑ පොජ්ජේ
    View attachment 160362
    machan mata ona me file picker eka ain karala. csv file eke location eka hard code karagnna.


    View attachment 160363
    machan mata ona me file picker eka ain karala. csv file eke location eka hard code karagnna.
    ------ Post added on Feb 13, 2022 at 10:45 AM

    Oke x.addeventlisterner eka athule function eka Window.onload event ekata file path eka hard code karala oka dala balapan...

    Prashne thiyenne file picker eken nikanma path string ekak nemei nm denne oka wada karanne na..

    Nikan x.files[0] eka console log ekak dala balanna mokakda set wela thiyenne kiyala
     

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,714
    12,619
    113
    127.0.0.1:8080/Kandy
    Oke x.addeventlisterner eka athule function eka Window.onload event ekata file path eka hard code karala oka dala balapan...

    Prashne thiyenne file picker eken nikanma path string ekak nemei nm denne oka wada karanne na..

    Nikan x.files[0] eka console log ekak dala balanna mokakda set wela thiyenne kiyala
    Local files js valin user prompt ekak nethuwa read karanna ba ban man danna widihata security issues nisa.

    remote files nam puluwan wei.

    ekko ithin ajax use kara nam wede lesi
     

    HAneo

    Well-known member
  • Jan 30, 2007
    12,970
    29,167
    113
    Homagama
    The way js behaves it does not allow you to access OS resources directly. so getting the full path for a file name is impossible.
    so that is why it created a hook File input. so you have to first go through browser native api's and it will return the file for you.

    I guess your requirement is to open a file without user intervention.
    so in order to do so you have to create a simple static file server and get the download URL. (Simple 2 min node js app , or asp.net core app or other simple app)
    and have the user upload all the files they need and arrange them. then you can create a config file

    Report1DocURL: 'https://elakiri.com/docs/report1.csv',
    Report2DocURL: 'https://elakiri.com/docs/report2.csv'

    then you can access Report1DocURL config variable and get the file from the server and have it processed.
    This is i think the slandered way to do this
    ------ Post added on Feb 14, 2022 at 1:04 PM