mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Deletion of image file on book deletion.
This commit is contained in:
parent
f51db4b9f6
commit
16a09e8ff6
@ -8,6 +8,7 @@ use BookStack\Services\ExportService;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Views;
|
use Views;
|
||||||
|
use File;
|
||||||
|
|
||||||
class BookController extends Controller
|
class BookController extends Controller
|
||||||
{
|
{
|
||||||
@ -134,6 +135,12 @@ class BookController extends Controller
|
|||||||
* @return $path
|
* @return $path
|
||||||
*/
|
*/
|
||||||
private function getBookCoverURL($image)
|
private function getBookCoverURL($image)
|
||||||
|
{
|
||||||
|
if(is_null($image))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$input = time().'-'.$image->getClientOriginalName();
|
$input = time().'-'.$image->getClientOriginalName();
|
||||||
$destinationPath = public_path('uploads/book/');
|
$destinationPath = public_path('uploads/book/');
|
||||||
@ -141,6 +148,7 @@ class BookController extends Controller
|
|||||||
$path = baseUrl('/uploads/book/').'/'.$input;
|
$path = baseUrl('/uploads/book/').'/'.$input;
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the page to confirm deletion
|
* Shows the page to confirm deletion
|
||||||
@ -250,6 +258,8 @@ class BookController extends Controller
|
|||||||
$book = $this->entityRepo->getBySlug('book', $bookSlug);
|
$book = $this->entityRepo->getBySlug('book', $bookSlug);
|
||||||
$this->checkOwnablePermission('book-delete', $book);
|
$this->checkOwnablePermission('book-delete', $book);
|
||||||
Activity::addMessage('book_delete', 0, $book->name);
|
Activity::addMessage('book_delete', 0, $book->name);
|
||||||
|
$file = basename($book->image);
|
||||||
|
File::delete('uploads/book/'.$file);
|
||||||
$this->entityRepo->destroyBook($book);
|
$this->entityRepo->destroyBook($book);
|
||||||
return redirect('/books');
|
return redirect('/books');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user