I'm a just a beginner and I need your help. EDIT : even when I search http://127.0.0.1:8000/storage/uploaded/the_filename I get 404 no found
I've already used php artisan storage:link
I get error 404 Not Found
when I use <iframe src="/storage/uploaded/{{$data->doc}}">
.
Even if I write <iframe src="/storage/uploaded/1628544440.docx">
I still get 404 Not Found
. 1628544440.docx
is the file name in DB and uploaded
folder.
The documents in the folder /storage/app/public/uploaded
have the same name of documents->doc
in the Database.
What can I change in the code?
In DocumentController
:
public function store(Request $request)
{
$request->validate([
'doc' => 'required',...
]);
$document = new document();
$file = $request->file('doc');
$filename = time().'.'.$file->getClientOriginalExtension() ;
$file->storeAs('uploaded', $filename);
$document->doc = $request->input('doc', $filename);
$document->candidate_id = $candidate_id;
$document->save();
}
public function show($id)
{
// to select a document that belongs to a candidate
$doc_id = DB::table('documents')
->select('id')
->where('candidate_id', $id)
->first()
->id;
$data = document::find($doc_id);
return view('candidate.document', compact('data'));
}
In candidate/document.blade.php
:
<iframe src="/storage/uploaded/{{ $data->doc }}"></iframe>
Thank you in advance.
./storage
for the current directory. – infinitezero/
refers to root./
refers to current and../
revers to the parent directory. – infinitezero