Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

delete file laravel dropzone

i have a problem when i delete file. My file is deleted correctly, but in my folder "storage/app/public" keep another folder with my file. I explain myself better, i′m uploading a file with dropzone plugin in laravel. When i upload a file for first time, created a folder with my video in this case, but when i save my changes in profile, dropzone also created a folder, ok??? also in first time, save in database my register with model AppModelsUpload but when i save my data y save model AppModelsRestaurant. well, my problem is that, when i delete my file (video in this case), dropzone delete my second folder created and in database drop row that it have a model AppModelsRestaurant y need that delete all folder, or else, if i have 1000 files in server with the same contain it′s a problem. I don′t know if i′m explaining correctly.

I have this code:

if ($restaurant->hasMedia($input['collection'])) {
                $restaurant->getFirstMedia($input['collection'])->delete();

                /**
                 * delete folder in storage/app/public
                 * delete entry in database model AppModelsUpload and Restaurant
                 */

                $result = $this->uploadRepository->clear($input['uuid']);
                Media::query()->where('model_type', '=', 'AppModelsUpload')->delete();

           }

this line $restaurant->getFirstMedia($input['collection'])->delete(); delete folder and entry in database perfectly when model is Restaurant and folder in storage, but not to do nothing.

with lines:

$result = $this->uploadRepository->clear($input['uuid']);
Media::query()->where('model_type', '=', 'AppModelsUpload')->delete();

i′m traying to delete folder and entries in database but nothing...

How can i delete my other folder and other entries in database?

regards


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...