<%!
    from kaithem.src.util import url
%>

<%include file="/pageheader.html"/>
<h2>Upload File To Module</h2>
<title>Upload File</title>
<section class="window paper">
    <form action="/modules/module/${url(module)}/uploadfileresourcetarget" method="POST" name="new" enctype="multipart/form-data">
        File Modules:
        <input required="required" name="file" type="file" id="upload"></input><br>
        <h3>Name</h3><input required="required" name="name" class="name" id="name" type="text"></input><br>
        <label><input type="checkbox" name="overwrite"></input>Replace Existing File if present</label><br>

        <input type="hidden" name="dir" value="${path|h}">
        <br><input value="Upload" type="submit">
    </form>
<section class="window paper">

<script>
lastMsg = ''
let u = document.getElementById("upload");
let filename = document.getElementById("name");
// display file name if file has been selected
u.onchange = function() {
    let input = this.files[0];
    let text;
    if (input) {
        //process input
        text = u.value.replace("C:\\fakepath\\", "");
    } else {
        text = "";
    }

    if (filename.value==lastMsg)
    {
        filename.value = text;
        lastMsg = text;
    }
    else{
        lastMsg= "hgfdxdfghjkluytfdxcvbnhjkuytgfcv bnmkliouhg"
    }
};
</script>
<%include file="/pagefooter.html"/>
