0

I have this code in html, which has a form to send files, but I would like to read these files directly from a path on the computer, how do I do that? I'm new to the language Thanks

const char* serverIndex = 
"<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>"
"<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>"
   "<input type='file' name='update'>"      
    "</form>"
 "<div id='prg'>Progresso: 0%</div>"
 "<script>"
  "$('form').submit(function(e){"
  "e.preventDefault();"
  "var form = $('#upload_form')[0];"
  "var data = new FormData(form);"
  " $.ajax({"
  "url: '/update',"
  "type: 'POST',"
  "data: data,"
  "contentType: false,"
  "processData:false,"
  "xhr: function() {"
  "var xhr = new window.XMLHttpRequest();"
  "xhr.upload.addEventListener('progress', function(evt) {"
  "if (evt.lengthComputable) {"
  "var per = evt.loaded / evt.total;"
  "$('#prg').html('Progresso: ' + Math.round(per*100) + '%');"
  "}"
  "}, false);"
  "return xhr;"
  "},"
  "success:function(d, s) {"
  "console.log('Sucesso!')"
 "},"
 "error: function (a, b, c) {"
 "}"
 "});"
 "});"
 "</script>";

Example:

I would like to read this file file:///C:/Users/Matheus/Desktop/test.bin

aSemy
  • 5,485
  • 2
  • 25
  • 51
Matt Dogg
  • 1
  • 1
  • Are you saying that the form works but you want to be able to have your web page read files from the computer without using the form or having any user interaction? – romkey Nov 15 '22 at 22:32
  • Exactly, is it possible to do this? – Matt Dogg Nov 15 '22 at 22:35
  • Does this answer your question? [How to read/write local files through a web page?](https://stackoverflow.com/questions/12023858/how-to-read-write-local-files-through-a-web-page) – romkey Nov 16 '22 at 04:51

0 Answers0