mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-09 11:16:39 -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)
|
||||
{
|
||||
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->save($file);
|
||||
} else {
|
||||
|
@ -200,12 +200,11 @@ class DashboardController extends Controller {
|
|||
}
|
||||
|
||||
// delete the associated image if one exists
|
||||
$image_file = base_path() . '/public/uploads/' . $request['model'] . '/' . $request['id'] . '.jpg';
|
||||
if (file_exists($image_file)) {
|
||||
if (!unlink($image_file)) {
|
||||
$image_file = base_path() . '/public/uploads/' . $request['model'] . '/img/' . $request['id'] . '.jpg';
|
||||
|
||||
if (file_exists($image_file) && !unlink($image_file)) {
|
||||
return 'image-delete-fail';
|
||||
}
|
||||
}
|
||||
|
||||
// Return a success
|
||||
return 'success';
|
||||
|
|
Loading…
Reference in a new issue