There is a task from the .docx document to import text into md. Is it possible to implement all this (file receipt) in the client part?

Closed due to the fact that the essence of the issue is incomprehensible by the participants of Jarvis_J , 0xdb , HamSter , ThisMan , Edward 16 Jul '18 at 8:29 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    This task, if there is no ready-made solution on the network, may take more than one week of development. - Stepan Kasyanenko
  • @StepanKasyanenko, I have implemented this in php using libraries. There I have difficulty with passing the path to the file using the ajax method. There was a desire to implement this on the client side, without creating ajax requests. - Tigran Arustamov
  • Well, in php you used libraries. If you find their analogues on js - you can try to solve on js. But for me, it's easier to deal with AJAX and paths. - Stepan Kasyanenko

1 answer 1

Yes, receiving a file on the client side (and processing its contents) is quite possible.

Example ( supported by most browsers, including mobile ):

function onFileLoad(elementId, event) { document.getElementById(elementId).innerText = event.target.result; } function onChooseFile(event, onLoadFileHandler) { if (typeof window.FileReader !== 'function') throw ("The file API isn't supported on this browser."); let input = event.target; if (!input) throw ("The browser does not properly implement the event object"); if (!input.files) throw ("This browser does not support the `files` property of the file input."); if (!input.files[0]) return undefined; let file = input.files[0]; let fr = new FileReader(); fr.onload = onLoadFileHandler; fr.readAsText(file); } 
 <input type='file' onchange='onChooseFile(event, onFileLoad.bind(this, "contents"))' /> <br> <div style="background: #e9e9e9"> <code id="contents"></code> </div> 

Next, you will have to process the content of the file (parsing docx, etc.), and this is another task.

  • And what if you use a temporary path to the file? - Tigran Arustamov
  • @TigranArustamov if the file is on the disk and the browser is supported, then the file should be read. - Peter Samokhin
  • I will try to use the temporary path - I will write what happened - Tigran Arustamov
  • @TigranArustamov what do you mean by "temporary way"? - Peter Samokhin
  • Something like this: blob: fiddle.jshell.net/2f386172-702f-47b5-b4eb-4a70c2f7bace - Tigran Arustamov