'Laravel file upload not parsed with "multipart/form-data"

I am trying a file upload which I've used before, but seems not to be working now

<form action="{{ route('media.upload')}}" method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="text" name="name" placeholder="title">
<input type="file" name="file">
<button type="submit" name="submit">Submit</button></form>

web.php

Route::group(['middleware' => 'auth:api'], function () {
Route::get('upload', function () {
    return view('upload');
})->name('upload');

api.php

Route::post('upload', 'UploadController@upload')->name('media.upload');

Controller Function

public function upload (Request $request)
{
    dd($request->all());
}

this is the error I'm getting, this is the only readable line 😑

"------WebKitFormBoundaryZIiC073OTmdxtEqAContent-Disposition:_form-data;_name" => b""_token"\r\n\r\nTZFHuu4liPLE6Esz2avGRlqLv9K8v1uhKgI7dWw8\r\n------WebKitFormBoundaryZIiC073OTmdxtEqA\r\nContent-Disposition: form-data

I can't use application/x-www-form-urlencode the file is not uploaded



Solution 1:[1]

I fixed it, thanks to @dgraham answer https://github.com/github/fetch/issues/505#issuecomment-293064470

The header plug-in I'm using had Content-type, I unset all headers except for Authorization and it worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mrBell