src/Media/Http/Controllers/MediaAdminController.php
public function postUpload(Request $request)
    {
        if (!$request->file('file')) {
            return [];
        }

        $filename = time().'-'.$request->file('file')->getClientOriginalName();
        $request->file('file')->move('uploads/media', $filename);

        foreach (\Config::get('flare-config.media.resize') as $sizeArray) {
            $newfilename = $sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$filename;
            Image::make('uploads/media/'.$filename)->fit($sizeArray[0], (array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]))->save('uploads/media/'.$newfilename);
        }

        $media = Media::create([
                            'name' => $request->file('file')->getClientOriginalName(),
                            'path' => $filename,
                            'extension' => $request->file('file')->getClientOriginalExtension(),
                            'mimetype' => $request->file('file')->getClientMimeType(),
                            'size' => $request->file('file')->getClientSize(),
            ]);

        $file = new \stdClass();
        $file->name = $media->name;
        $file->url = url('uploads/media/'.$media->path);
        $file->thumbnailUrl = url('uploads/media/100-100-'.$media->path);
        $file->type = $media->mimetype;
        $file->size = $media->size;

        $object = new \stdClass();
        $object->files = [$file];

        return json_encode($object);
    }
public function postUpload(Request $request)
    {
        if (!$request->file('file')) {
            return [];
        }

        $filename = time().'-'.$request->file('file')->getClientOriginalName();
        $request->file('file')->move('uploads/media', $filename);

        foreach (\Config::get('flare-config.media.resize') as $sizeArray) {
            $newfilename = $sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$filename;
            Image::make('uploads/media/'.$filename)->fit($sizeArray[0], (array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]))->save('uploads/media/'.$newfilename);
        }

        $media = Media::create([
                            'name' => $request->file('file')->getClientOriginalName(),
                            'path' => $filename,
                            'extension' => $request->file('file')->getClientOriginalExtension(),
                            'mimetype' => $request->file('file')->getClientMimeType(),
                            'size' => $request->file('file')->getClientSize(),
            ]);

        $file = new \stdClass();
        $file->name = $media->name;
        $file->url = url('uploads/media/'.$media->path);
        $file->thumbnailUrl = url('uploads/media/100-100-'.$media->path);
        $file->type = $media->mimetype;
        $file->size = $media->size;

        $object = new \stdClass();
        $object->files = [$file];

        return json_encode($object);
    }
public function postUpload ( Request $ request ) { if ( ! $ request -> file ( 'file' ) ) { return [ ] ; } $ filename = time ( ) . '-' . $ request -> file ( 'file' ) -> getClientOriginalName ( ) ; $ request -> file ( 'file' ) -> move ( 'uploads/media' , $ filename ) ; foreach ( \ Config :: get ( 'flare-config.media.resize' ) as $ sizeArray ) { $ newfilename = $ sizeArray [ 0 ] . '-' . ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) . '-' . $ filename ; Image :: make ( 'uploads/media/' . $ filename ) -> fit ( $ sizeArray [ 0 ] , ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) ) -> save ( 'uploads/media/' . $ newfilename ) ; } $ media = Media :: create ( [ 'name' => $ request -> file ( 'file' ) -> getClientOriginalName ( ) , 'path' => $ filename , 'extension' => $ request -> file ( 'file' ) -> getClientOriginalExtension ( ) , 'mimetype' => $ request -> file ( 'file' ) -> getClientMimeType ( ) , 'size' => $ request -> file ( 'file' ) -> getClientSize ( ) , ] ) ; $ file = new \ stdClass ( ) ; $ file -> name = $ media -> name ; $ file -> url = url ( 'uploads/media/' . $ media -> path ) ; $ file -> thumbnailUrl = url ( 'uploads/media/100-100-' . $ media -> path ) ; $ file -> type = $ media -> mimetype ; $ file -> size = $ media -> size ; $ object = new \ stdClass ( ) ; $ object -> files = [ $ file ] ; return json_encode ( $ object ) ; }
Process a File Upload from the Jquery File Uploader.

@param Request $request

@return string
Process a File Upload from the Jquery File Uploader .