dpinney / omf

The Open Modeling Framework for smart grid cost-benefit analysis.
https://omf.coop
GNU General Public License v2.0
112 stars 60 forks source link

Figure out what to where we can use Hongwei's great file upload code. #176

Closed dpinney closed 9 years ago

dpinney commented 10 years ago

Example html:

<tr>
    <td>Upload file</td>
    <td>SCADA file (.csv) 
        <input type='file' name='scadaFile' class='scadaFile' accept='.csv' onchange='handle_files(this.files)'>
        <input type='hidden' class='hiddenScadaFile'>
    </td>
</tr>

Then:

function handle_files(files) {
    // read file to a hidden input field
    reader = new FileReader();
    reader.readAsText(files[0]);
    reader.onload = loaded;
    function loaded(evt){
        evt.target.result;
        document.getElementsByClassName('hiddenScadaFile').value = reader.result;
    }
}

Also see: http://www.html5rocks.com/en/tutorials/file/dndfiles/

cshjin commented 10 years ago

I am digging it. Actually, my previous upload file method is not that secure enough. I also need to check the security of uploading file data.

dpinney commented 10 years ago

Hmm, actually let's move this out of the Q2 event and think about it once we've got a better issue list for Q2.

dpinney commented 9 years ago

Used/fixed with 62b0372586624aec2de0cfbdf11dc85aa120f34b