4ndro1d's avatar

Accessing UploadedFile from request/input is null

I am trying to send some files via mail:

  Mail::send('vendor.notifications.email', $maildata, function($message) use ($input)
  {
    $message->to(Config::get('constants.bywood_mail'));
    $message->subject(Lang::get('platform.message_new_user_subj'));
    $message->from(Config::get('constants.bywood_mail'));

    if(Input::file('files')){
      foreach(Input::file('files') as $file) {
        $message->attach( $file->getRealPath(), array(
          'as' =>  $file->getClientOriginalName(), 
          'mime' =>  $file->getMimeType())
        );
      }
    }

But although

  var_dump($input);

shows that there are file pathes available:

  'files' => 
    array (size=3)
      0 => string 'layer-slider-rtl.js' (length=19)
      1 => string 'master-slider-fw.js' (length=19)
      2 => string 'mouse-wheel.js' (length=14)

the following just gives me null values:

  var_dump(Input::file('files'));
  var_dump($request->file('files'));

I am trying to solve this problem for days already and appreciate any help. Please note that I am trying to do this in the RegisterController class where I am overriding the register method.

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

check you are doing the upload correctly

do you have this in your form tag enctype="multipart/form-data"

1 like
rdelorier's avatar

Have you tried some of the solution from other posts in this forum, there have been multiple related threads in just the past week.

Please or to participate in this conversation.