afoysal's avatar

File Upload

I am adding input type file using jQuery like below.

$("#company_logo .ri-close-line").click(function() {                
                $("#company_logo").html('<input type="file" class="form-control-file" name="company_logo" />');
});

My Form has multipart option like below

<form action="{{ route('update_profile') }}" method="POST"
                                            enctype="multipart/form-data">
                                            @csrf
<div class="form-group">
      <label for="exampleFormControlFile1">Company Logo</label>
       <div id="company_logo">
      @if ($profile_data['company_logo'])
      <img src="https://sometext" height="100" width="100" />
     <i class="ri-close-line" title="Click to Update Image"></i> 
      @else
     <input type="file" class="form-control-file" name="company_logo" />
      @endif                                                
      </div>
 </div>

My controller function is like below

public function update_profile(Request $request)
{
	dd($request->file('company_logo'));
}

I am getting output like below

error

But when I am debugging in controller (dd($request);) I am getting empty output like below.

error

0 likes
14 replies
automica's avatar

Can you post your controller method?

1 like
afoysal's avatar

Thanks @automica . I am debugging now.

public function update_profile(Request $request)
{
	dd($request);
}
MichalOravec's avatar

What do you get with $request->file('company_logo') ?

dd($request->file('company_logo'));
1 like
wingly's avatar

You add an input but do you select a file ? Further more where do you add your input is it part of your form ?

1 like
wingly's avatar

The obvious question is do you select a file before you submit ?

1 like

Please or to participate in this conversation.