mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-22 07:54:11 -05:00
Clean up some things in the dashboard controller and put image uploads into an img subfolder
This commit is contained in:
parent
2b433f9daf
commit
d02aa7e923
1 changed files with 5 additions and 6 deletions
|
@ -104,7 +104,7 @@ class DashboardController extends Controller {
|
||||||
public function postImageUpload(Request $request)
|
public function postImageUpload(Request $request)
|
||||||
{
|
{
|
||||||
if ($request->hasFile('file')) {
|
if ($request->hasFile('file')) {
|
||||||
$file = base_path() . '/public/uploads/' . $request['model'] . '/' . $request['id'] . '.jpg';
|
$file = base_path() . '/public/uploads/' . $request['model'] . '/img/' . $request['id'] . '.jpg';
|
||||||
$image = Image::make($request->file('file'));
|
$image = Image::make($request->file('file'));
|
||||||
$image->save($file);
|
$image->save($file);
|
||||||
} else {
|
} else {
|
||||||
|
@ -200,11 +200,10 @@ class DashboardController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the associated image if one exists
|
// delete the associated image if one exists
|
||||||
$image_file = base_path() . '/public/uploads/' . $request['model'] . '/' . $request['id'] . '.jpg';
|
$image_file = base_path() . '/public/uploads/' . $request['model'] . '/img/' . $request['id'] . '.jpg';
|
||||||
if (file_exists($image_file)) {
|
|
||||||
if (!unlink($image_file)) {
|
if (file_exists($image_file) && !unlink($image_file)) {
|
||||||
return 'image-delete-fail';
|
return 'image-delete-fail';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a success
|
// Return a success
|
||||||
|
|
Loading…
Reference in a new issue