Reset an input field

I have a function that runs when a file is selected to be uploaded

function checkFile(e) {

    var file_list =;

    for (var i = 0, file; file = file_list[i]; i++) {
        var sFileName =;
        var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase();
        var iFileSize = file.size;
        var iConvert = (file.size / 10485760).toFixed(2);

        if (!(sFileExtension === "gif" || sFileExtension === "png" || sFileExtension === "jpg" || sFileExtension === "bmp") || iFileSize > 5000000) {
            txt = "File type : " + sFileExtension + "\n\n";
            txt += "Size: " + iConvert + " MB \n\n";
            txt += "Please make sure your image has a valid extension (gif, bmp, jpg, png) and is less than 500 KB.\n\n";
			//document.getElementById("?").value = "";

After the alert pops up im trying to figure out how to reset the field so they have to choose another file to upload…
I sort of started it but dont know what to replace ? with
Heres the result

Im trying to reset the field though…

does the field have an ID in the first place? otherwise you need to traverse the DOM tree to find the field’s element.

PS. I’m not sure you can reset a file input like that …

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.