samedi 28 janvier 2017

Laravel 5 upload script files

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 and php.

  • 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.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2k35ARL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire