upload fileSize does not work

upload fileSize does not work

LapointeLapointe Posts: 430Questions: 81Answers: 4

Hello

I receive this message (file exceeds...)

with this code (working correctly for file extension filter)

// standart filesize validator
->validator( Validate::fileSize( 3072000, 'La taille de chaque fichier ne peut exéder 3Mo' ) )
// custom filesize validator
->validator( function ( $file ) {if ( $file['size'] >= 2048000 ) {return "La taille de chaque fichier ne peut exéder 2Mo";}return null;})
//
->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif', 'pdf' ), "Seuls les fichiers de type PDF ou image sont acceptés" ) )
fileExtensions( string[] $valid, string $errorMessage ) - Check that the uploaded file's extension is one of those provided in the valid list. This check is case-insensitive, so png in the list would accept .PNG, .pnG, etc, as valid extensions). Also, it is worth noting that you should not rely upon extension validation only for secure validation as it is trivial to modify a file name extension. It is however a useful and simple sanity check.
fileSize( integer $size, string $errorMessage ) - Check that the uploaded file is equal to or below a given size (in bytes).

(I did try with fileSize and $file['size'])

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,941Questions: 87Answers: 415
    edited October 2019 Answer ✓

    Searching for "File exceeds maximum" in the Editor source code I found this:

    You need to change this parameter in your PHP ini:

    If this parameter isn't bigger than your own limit you'll never see the French error message you defined.

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hi @rf1234

    Of course...

    Thanks you

This discussion has been closed.