This is my first project in laravel 5.4 and php 5.6, and i want multi-upload image using multiple input with using move() from following libraries. But it only upload the file from the first input and give me error
FileNotFoundException The file "...tmp" does not exist in MimeTypeGuesser.php line 116
this is my upload code from my controller
if($request->hasFile('foto'))
{
$number = 1;
foreach ($request->file('foto') as $file) {
$file->move('images/'.$id,'foto'.$number. '.' . $file->extension());
$number++;
}
}
this is my form in view
<form action='' method="post" enctype="multipart/form-data">
<span>Foto</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto2</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto3</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto4</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto5</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto6</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto7</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="file-field input-field col s6">
<div class="btn teal darken-1">
<span>Foto8</span>
<input name="foto[]" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Pilih pas foto">
</div>
</div>
<div class="col s12">
@if (count($errors) > 0)
@foreach ($errors->all() as $error)
<p></p>
@endforeach
@endif
</div>
<div class="input-field col s12 center">
<input type="submit" value="Submit" class="waves-effect waves-light btn cyan">
</div>
</form>
and when using dd($request->foto) it give an array with all the image in it. Can you tell me where is my mistake? and how do i solve this problem
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire