Comments (5)
@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
orfile_name
attached to the user in theusers
table or themedia
table which comes with the Cloudinary package. - Use the
public_id
to make adestroy
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.
@dela-dels I can't find the public_id - The error is: "Missing required parameter - public_id".
Can you help me please??
from cloudinary-laravel.
@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 thedestroy()
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
orfile_name
attached to the user in theusers
table or themedia
table which comes with the Cloudinary package.- Use the
public_id
to make adestroy
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.
I have solved my problem :)))
I appreciate your help, thank you so much
You should add into your documentation about:
from cloudinary-laravel.
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)
- Error Must supply cloudName when laravel config is cached HOT 2
- ERROR: Invalid configuration, please set up your environment HOT 2
- ERROR: Call to undefined method CloudinaryLabs\CloudinaryLaravel\CloudinaryAdapter::getPathPrefix()
- Upload File from Disk -> MediaAlly
- Laravel 11 Support. HOT 2
- Testcase Failed HOT 9
- 413 Request Entity Too Large
- Trait "League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait" not found
- message : "Call to undefined method CloudinaryLabs\\CloudinaryLaravel\\CloudinaryEngine::getSecureUrl()"
- Support For Laravel Lumen HOT 1
- Failed to copy image using Storage::disk('cloudinary')->copy() method HOT 2
- Can't find doc's on how to delete a file from my API HOT 7
- Get video url by public_id returning an empty string HOT 3
- NotSupportingVisibilityTrait not found HOT 33
- Add custom analytics code for generated Cloudinary URLs HOT 1
- Publish Laravel 10 support to Packagist HOT 2
- Create folders with the SDK HOT 1
- How to set CLOUDINARY_URL HOT 1
- Unable to locate a class or view for component [cld-upload-button]. HOT 7
- How to get upload image link from widget "x-cld-upload-button" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudinary-laravel.