1

Has anyone tried doing this? I have a textarea made with codemirror fill and submit to a server which does some analysis and returns some data. I want to have the option to upload a file (via button or drop) but while I'm sure there is a way to do so with a normal textarea I wonder if it works with codemirror.

(It's in html/js)

Thanks!

Mosho
  • 7,099
  • 3
  • 34
  • 51

1 Answers1

0

You can use File API (FileReader) for reading file and setting his value to CodeMirror editor.

var reader = new FileReader();

reader.readAsText(f);
reader.onload = function(){ cm.setValue(reader.result); }