Your input
is correct except for the fact that enctype="multipart/form-data"
this is an attribute of form
and not of input
But with the form
correct this does not interfere in sending
Thus, despite not having posted your form
, the error must be on this or your route, to make a small test put on 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 I demonstrate 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 in your form
if this with the attribute
enctype="multipart/form-data"
If it still doesn’t work check in your form if you have the correct method:
method="post"
If it still doesn’t work check your route if you have the correct method, e.g.:
Route::resource('annex', 'AnnexController', [
'only' => [
'store',
]
]);
or
Route::post('annex', 'AnnexController@store');
in the form is it enabled to send email? p.x:
{{ Form::open(array('url' => '/form', 'files' => true)) }}
– juniorb2ss
Email or file? Thank you for the answer. I am using the normal html form tag without facade. What would HTML look like?
– Gabriel Augusto
the
enctype="multipart/form-data"
is not in theinput
file
is on the tagform
, example,<form enctype="multipart/form-data" ....>
an example of the form: https://www.w3schools.com/tags/att_form_enctype.asp– novic
Yes, it is enabled in the form.
– Gabriel Augusto
Using ajax to send php or Submit in form?
– twsouza
@Gabrielaugusto a check in the answer I posted, if still your problem is not solved, post your full form and the content obtained with the DD
$request
– Mateus