Your input
is correct except that enctype="multipart/form-data"
is an attribute of form
and not input
But with form
correct this does not hinder sending
So, although you have not posted your form
, the error should be in this or your route, to do a little test I put this form
:
<form action="api/annex" method="post" enctype="multipart/form-data">
<label for="recipient" class="control-label">Foto:</label>
<input id="foto" type="file" name="foto" accept="image/*" enctype="multipart/form-data">
@if ($errors->has('foto'))
<span class="help-block">
<strong>{{ $errors->first('foto') }}</strong>
</span>
@endif
</div>
<input type="submit">
</form>
And this worked correctly, as shown below:
Request {#39 ▼
#json: null
#convertedFiles: null
#userResolver: Closure {#123 ▶}
#routeResolver: Closure {#124 ▶}
+attributes: ParameterBag {#41 ▶}
+request: ParameterBag {#40 ▶}
+query: ParameterBag {#47 ▶}
+server: ServerBag {#44 ▶}
+files: FileBag {#43 ▼
#parameters: array:1 [▼
"foto" => UploadedFile {#28 ▼
-test: false
-originalName: "Dassad.png"
-mimeType: "image/png"
-size: 346505
-error: 0
path: "/tmp"
filename: "phpJRjAf5"
basename: "phpJRjAf5"
pathname: "/tmp/phpJRjAf5"
extension: ""
realPath: "/tmp/phpJRjAf5"
aTime: 2017-12-28 17:26:39
mTime: 2017-12-28 17:26:39
cTime: 2017-12-28 17:26:39
inode: 1079759
size: 346505
perms: 0100600
owner: 33
group: 33
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
]
}
+cookies: ParameterBag {#42 ▶}
+headers: HeaderBag {#45 ▶}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: null
#pathInfo: "/api/annex"
#requestUri: "/apiapp/public/api/annex"
#baseUrl: "/apiapp/public"
#basePath: null
#method: "POST"
#format: null
#session: null
#locale: null
#defaultLocale: "en"
-isHostValid: true
-isClientIpsValid: true
-isForwardedValid: true
basePath: "/apiapp/public"
format: "html"
}
So check out your form
if it has the attribute
enctype="multipart/form-data"
If it still does not work check out your form if you have the correct method:
method="post"
If it still does not work check your route if you have the correct method, eg:
Route::resource('annex', 'AnnexController', [
'only' => [
'store',
]
]);
or
Route::post('annex', 'AnnexController@store');