Is it possible to validate the size and type of input=file in html5

前端 未结 3 1321
一整个雨季
一整个雨季 2020-11-28 05:25

I was reading this http://dev.w3.org/html5/markup/input.file.html, but I only found the \"accept\" attribute.

I tried this



        
3条回答
  •  一生所求
    2020-11-28 05:44

    if your using php for the backend maybe you can use this code.

    // Validate image file size
    if (($_FILES["file-input"]["size"] > 2000000)) {
        $msg = "Image File Size is Greater than 2MB.";
        header("Location: ../product.php?error=$msg");
        exit();
    }  
    

提交回复
热议问题