Coder Social home page Coder Social logo

Comments (5)

dela-dels avatar dela-dels commented on August 10, 2024

@hotfuzz123 I think the only way you can do this right now is if you are storing the public_id(which could be the filename) of the uploaded file in your database. Then you can use that to delete the resource from Cloudinary by supplying the public_id to the destroy() method of the Cloudinary API.

So the flow could be something like this (using the example of a user updating their profile picture):

  • User enters details in the profile picture form to be updated.
  • Before the actual update is done, you retrieve the public_id or file_name attached to the user in the users table or the media table which comes with the Cloudinary package.
  • Use the public_id to make a destroy call to delete the previous image.
  • upload the new image to Cloudinary and update the respective tables with the new values.

Something along these lines should probably work.

from cloudinary-laravel.

hotfuzz123 avatar hotfuzz123 commented on August 10, 2024

@dela-dels I can't find the public_id - The error is: "Missing required parameter - public_id".
Can you help me please??

Screenshot 2021-06-17 234627

from cloudinary-laravel.

dela-dels avatar dela-dels commented on August 10, 2024

@hotfuzz123 I made mention in my previous comment (see below) that you will need to store the public_id as a field in your database column. you are getting that error because the $slider object doesn't have a public_id property. You may have to update your database table to reflect that.

@hotfuzz123 I think the only way you can do this right now is if you are storing the public_id(which could be the filename) of the uploaded file in your database. Then you can use that to delete the resource from Cloudinary by supplying the public_id to the destroy() method of the Cloudinary API.

So the flow could be something like this (using the example of a user updating their profile picture):

  • User enters details in the profile picture form to be updated.
  • Before the actual update is done, you retrieve the public_id or file_name attached to the user in the users table or the media table which comes with the Cloudinary package.
  • Use the public_id to make a destroy call to delete the previous image.
  • upload the new image to Cloudinary and update the respective tables with the new values.

Something along these lines should probably work.

from cloudinary-laravel.

hotfuzz123 avatar hotfuzz123 commented on August 10, 2024

I have solved my problem :)))
I appreciate your help, thank you so much
You should add into your documentation about:

  • add public_id as a field in database column.
  • add Cloudinary::destroy();
  • Here is my example:
    Screenshot 2021-06-18 020705

from cloudinary-laravel.

dela-dels avatar dela-dels commented on August 10, 2024

Happy to help @hotfuzz123
Just a quick tip. $slider->update($request->all()) should probably be changed to $slider->update($request->validated()) which is much safer, the former, which you are doing is dangerous and can easily let attackers inject unwanted stuff.

That said since you have been able to solve your issue, kindly close this issue. All the best.

from cloudinary-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.