so im running to a wall. I want to save data in my project folder and display with filename in database. But it seems none of it works.
So im using this function to store the data image
public function insertproof(Request $request)
{
$id = $request['id'];
if ($request->hasFile('rent_proof')){
$filepath = $request->file('rent_proof')->store('public');
$result = rent::where('id',$id)->first();
$result->rent_proof=$filepath;
$result->save();
}
return redirect()->back()->with('status', 'proof updated');
}
this function gives me 'public/{filename}' on database and it saved at storage/app/public
with storage:link it also gives me public/storage
according to documentation, i can use something like this
but i cant seems to load it through my view
<button class="btn-success editrent"
data-id=""
data-proof=""
data-toggle="modal" data-target="#modal-insertproof">
<i class="fa fa-pencil" align="center">Input proof</i>
</button>
this is my js
$(document).ready(function(){
$(document).on('click', '.editrent', function() {
$('#idrent').val($(this).data('id'));
$('#rentproof').val($(this).data('proof'));
});
my modal after i click
<form method="POST" action="" enctype="multipart/form-data">//use the insertproof controller
<div class="form-group">
<input type="file" class="form-control" name="rent_proof" id="rentproof" >
<img style="max-width: calc(100% - 20px)" src="">
</div>
</form'
im so confused, thanks for the care. this seems like a long post, sorry for that.
Console
GET http://127.0.0.1:8000/storage/public/HXVTfZo9UKuFRJCanOWrCeQw7flyJM9N8uUxUR5d.png 404 Not Found
what is my fault in here ? i try to fix this but its like back on forth with public folder. thanks for the help..
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire