DEV Community

Cover image for File upload -> Filesize
Frank Wisniewski
Frank Wisniewski

Posted on • Updated on


File upload -> Filesize

It happens again and again that inexperienced users want to upload unnecessarily large files to the server.

With this little onchange oneLiner you can check that before uploading.

Use data-mfs=.... (....=fileSize)

<!DOCTYPE html>
<html lang=de>
  <meta charset=UTF-8>
    <h1>check max filesize</h1>
    <input type=file  
           data-mfs=100000 onchange="this.setCustomValidity(this.files[0].size>this.dataset.mfs?'to big!!':'')" 
    <input type=submit>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.