This code creates an HTML document with a form for uploading a file. The form contains a file input field and a button to trigger the “upload” action. The form is named “upload”. The script block defined in the head of the HTML document contains a function named getSize().

When the user selects a file and clicks the upload button, the onClick event of the button is triggered, which calls the getSize() function. The getSize() function uses the ActiveXObject to create an instance of the FileSystemObject, which allows the script to interact with the file system of the user’s computer.

The script then assigns the value of the file input field to a variable named ‘filepath’ using the document.upload.file.value, which is the file path of the selected file. The script uses the getFile() method of the FileSystemObject instance to get the file object from the filepath and assigns it to the variable ‘thefile’.

The script then uses the .size property of the file object to get the size of the selected file in bytes and assigns it to the variable ‘size’.

The script uses an if-else statement to check if the size of the file is less than 1MB (1048576 bytes). If the file size is less than 1MB, an alert message is displayed saying “FIle upload”. If the file size is greater than or equal to 1MB, an alert message is displayed saying “file must be select < 1 MB” to inform the user that the selected file is too large.

function getSize()
    var myFSO = new ActiveXObject("Scripting.FileSystemObject");
    var filepath = document.upload.file.value;
    var thefile = myFSO.getFile(filepath);
    var size = thefile.size;
    if(size < 1048576)
        alert("FIle upload");
        else {
            alert("file must be select < 1 MB");
<form name="upload">
<input type="file" name="file">
<input type="button" value="upload"

This code provides a client-side file size limit check using javascript, it prevents the user from uploading files that are larger than the specified limit. This is done by reading the size of the selected file on the client-side and comparing it to the specified limit before allowing the file to be uploaded.