lundi 26 août 2019

laravel check file extension in upload form

this is the html form:

<form method = "post" action="...">
   <input type="text" name="subject" />
   <input type="file" type="files['new']['file']"/>
   <input type="text" type="files['new']['name']"/>
</form>

Now I try read in server (laravel).

   public function chechkForm(request $request){
      $input = $request->all();
      dd(input['files']['new']['file' );
   }

the result is:

UploadedFile {#1356 ▼
  -test: false
  -originalName: "GK-Footer-Logo.png"
  -mimeType: "image/png"
  -error: 0
  #hashName: null
  path: "C:\Users\ali\AppData\Local\Temp"
  filename: "phpC3BF.tmp"
  basename: "phpC3BF.tmp"

Now I try these to print mimetype:

$input['new0']['content']['mimeType']

or

$input['new0']['content']->mimeType

or

$input['new0']['content']->mimeType()

what is my wrong? I get for all of them 'error'!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire