Level 73
What errors do you get?
I'm confused about this
before this thread appeared I had a problem downloading the file then I tried to fix it and it worked
but after it has been successfully repaired the download cannot be opened
I tried migrate:fresh and tried to upload again, when the download process again it can't
upload function
public function store()
{
$upload = Upload::create($this->validateRequest());
$this->storeImage($upload);
flash()->success('file berhasi ditambahkan');
return redirect()->back();
}
private function validateRequest(){
return tap(request()->validate([
'record_id' => 'required',
'title' => 'required',
'image' => 'required|image|max:5000',
]), function(){
if(request()->hasFile('image')){
request()->validate([
'image' => 'required|image|max:5000',
]);
}
});
}
private function storeImage($upload){
if(request()->has('image')){
$upload->update([
'image' => request()->image->store('uploads','public'),
]);
$image = Image::make(public_path('storage/'. $upload->image));
$image->save();
}
}
function download
public function download($id)
{
$image = Upload::find($id);
return Storage::download($image->image);
}
Done i change with this
return Storage::disk('public')->download($image->image);
Please or to participate in this conversation.