Ap3twe

Images not saving to path when I update my database?

Posted 6 days ago by Ap3twe

My database has images stored. I wanna add a new field with an image. All my updates are working correctly apart from images. I am updating the table inserting an image. When I hit the endpoint, I get the values in the database but the file is not saved in the folder. I will show you how I tried none is working. NB: Saving images to the database I have a working method for adding and retrieving it. The problem is adding a field datatype image to an already created database. Thank you

1 method. I get the name of the files in the database but the path is not in the folder

// Update controller
 public function update(project $project, request $request){

        if ($request->hasFile('lab_quote')){
            // get file Name
            $quotenameWithExt = $request->file('lab_quote')->getClientOriginalName();
            //The image path and name
            $quotefilename = pathinfo($quotenameWithExt, PATHINFO_FILENAME);
             // get the exxtension
            $quoteextension = $request->file('lab_quote')->getClientOriginalExtension();
            // Name append a time stamp
            $labquotefileNameToStore = $quotefilename.'_' .time(). '.' . $quoteextension;
            // Move the file to the folder
            // $stlpath = $request->file('stl_image')->storeAs('public/uploads', $stlfileNameToStore);
            $qtlpath = $request->file('lab_quote')->storeAs('public/uploads/thumbnails', $labquotefileNameToStore);
            // Resize
            $quote = public_path('storage/uploads/thumbnails'. $labquotefileNameToStore);
            $qto = Image::make($_FILES['lab_quote']['tmp_name']);
            $qto->resize('443','313');
            $qto->save($quote);

        }
$project->lab_quote = request('lab_quote');
 $project->save();

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.