Search code examples
htmlupload

Is there a maximum size for a file upload through HTML form?


I want users on my site to be able to upload large files (say up to 1GB), through html form. What I have so far, which works:

  <h1>Upload new File:</h1>
  <form method=post enctype=multipart/form-data>
    <input type=file name=file>
    <input type=submit value=Upload>
  </form>

Will this work for large files ? Or should I use another way (considering that I'm a beginner in webdev) ? I can't find references of a limitation on file size in html5 documentation, and only found ways to limit file size on SO (e.g. Limit the size of an file upload (html input)).


Solution

  • No, there is no size upload limit in Html input type "file"...

    Following are the way if you want to check file uploaded size.

    if (typeof FileReader !== "undefined") {
    var Filesize = document.getElementById('fileId').files[0].size;}
    

    There are several configuration parameters that can affect the file upload. These configuration parameters have to be setup right for the file uploads to work fine.

    => The folder in which the files are saved should be writable by the script. This is obvious but might be overlooked. The folder must be writable by the script means the web server user (usually www-data ) should have write access to the folder. So setup the folder permissions right. If you have shell access, the folder permissions can be updated using the 'chmod' command easily. If you don't have shell access, or if you have a shared hosting account, updating the folder permissions can be a little tricky. See if your hosting control panel has this feature.

    => The websever configuration The web server would have a configuration setting that (1) allows/disallows file uploads (2) sets a limit on the size of the file upload. Here are the typical settings you have to check (for PHP)

    1. memory_limit
    2. upload_max_filesize
    3. post_max_size