//////////////////////////////////////////////////////////////////////////////// $app->post('/pictures/upload/', function () use($app) { $auth = $app->container->resolve('Eman\\ServiceProvider\\Authentication'); if (!$auth->hasAccess('admin')) { $app->halt('Go Away!', 403); } $pictures = []; foreach ($_FILES as $file) { try { $img = Intervention\Image\Image::make($file['tmp_name']); $storename = Phrenetic\StoreFile::instance('pictures')->add($file['tmp_name']); $picture = new RMAN\Models\ORM\Picture(['type' => $file['type'], 'name' => $file['name'], 'storename' => $storename]); $picture->width = $img->width; $picture->height = $img->height; $picture->save(); $pictures[] = $picture->toArray(); } catch (Exception $e) { $pictures[] = ['error' => $e->getMessage()]; } } $response = $app->response(); $response['Content-Type'] = 'application/json'; $response->body(json_encode($pictures)); }); $app->get('/pictures/display/:storename', function ($storename) use($app) { $store = new Phrenetic\StoreFile('pictures'); $picture = RMAN\Models\ORM\Picture::where('storename', $storename)->where('default', 1)->first(); if (empty($picture)) { die('FOOBAR'); } $response = $app->response();