Kris99's avatar

Upload/Picture form update images with deleting

Hey!

I have a little bit problem. I hope someone can help me. I Upload images in Orchid Panel, and attach them a Model, it is working, but when I try to update images an exist Model like deleting, the image still is on storage, and after refresh it is appeared again. No error message in Console (like javascript), or from laravel.

image

After upload I try to delete it in dropzone with X, After delete Post in attachments table is not deleted I worked from original Docs ( BTW. in list sort doesnt work too, icons appeared, clickable, but after click doesnt happened anything.)

Delete function

    public function remove(Post $post)
    {
		$post->attachment->each->delete();

                $post->delete();
		//Storage::delete($post->attachment);

        Alert::info('You have successfully deleted the post.');

        return redirect()->route('platform.post.list');
    }

CreateOrUpdate

  public function createOrUpdate(Post $post, Request $request)
    {
		
                  $request->validate([
			'post.title' => 'required',
		   ]);

		$post->fill($request->get('post'))->save();
    
		$post->attachment()->syncWithoutDetaching(
			$request->input('post.attachment', [])
		);

        Alert::info('You have successfully created an post.');

        return redirect()->route('platform.post.list');
}

Upload form

	Upload::make('post.attachment')
					->acceptedFiles('image/*,.psd')
					->title('Upload image files'),
0 likes
5 replies
ZohaibAhmed's avatar

@Kris99 you can use an extension method in image uploading time like that, f ($request->picture) {

        $file = $request->file('picture');
        $filename = $file->getClientOriginalName();
        $file->move(public_path('you can write on your path'), $filename);
        $user->picture = $filename;
    }

Please or to participate in this conversation.