I'm trying to upload a PHP script via upload form but Laravel 5 Validator rejects it.
Here's an example:
$input_name = 'myfile';
$requirements = 'mimes:text/x-php|required|max:10000';
$file = array($input_name => Input::file($input_name));
$rules = array($input_name => $requirements);
$validator = Validator::make($file, $rules);
if ($validator->fails()) { // The fail occurs here
echo Input::file($input_name)->getMimeType(); // the output is text/x-php
}
Debug data:
-
I've also made attempts to define the mime type as
x-php
andphp
. -
At the terminal
file --mime-type test.php
returns text/x-php -
Laravel
getMimeType()
function also returns text/x-php -
The test.php file is small enough so It's not the size limit.
-
The same code works for images if defined as
mimes:jpeg,jpg,png,gif|required|max:10000
Does anyone know how the script files of any type should be defined in the validator?
Thanks for the help in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire