Monday, January 30, 2017

Image uploading from local pc in Laravel:



:Image uploading from local pc in laravel:

->  Below code Set in .env file:

#GOOGLE STORAGE
GOOGLE_CLOUD_PROJECT_ID=mediktiv
GOOGLE_CLOUD_KEY_FILE=C:/xampp/htdocs/mediktiv/mediktiv-clinic/storage/key/Mediktiv-8e7253bbb6d0.json
GOOGLE_CLOUD_STORAGE_BUCKET=mediktiv-storage

->  Put Mediktiv-8e7253bbb6d0.json file in mediktiv-clinic/storage/key/

-> Search cacert.pem file in google and save in c:\windows folder  


-> Put  cacert.pem  file in c:\windows

-> In php.ini file remove comment to this code: curl.cainfo and set below code.
o   curl.cainfo = "C:\Windows\cacert.pem"
-> Routes/web.php :
o   Route::get('/image/{prefix}/{folder}/{file}', ['as' => 'get_image', 'uses' => 'FileController@get_image']);
o   Route::get('/file/{folder}/{file}', ['as' => 'get_file', 'uses' => 'FileController@get_file']);
-> App/Helpers: helpers.php
-> Config\filesystems.php
-> Filecontroller.php
-> fileStorage.php
-> FileAcl.php
-> Config\image.php
-> In Clinic controller file:
o   In updateCenterDetail function :

$file = $request->file('image_profile');

        $file_id = storage($file, [
            'model' => ['status' => 'assign', 'visibility' => 'public'],
            'image' => ['w' => 400, 'h' => 400]
        ]);

-> Config\app.php
o   Zizaco\Entrust\EntrustServiceProvider::class,
o   Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
o   Intervention\Image\ImageServiceProvider::class,

o   'Entrust'   => Zizaco\Entrust\EntrustFacade::class,
o    'Image' => Intervention\Image\Facades\Image::class,
o    'Debugbar' => Barryvdh\Debugbar\Facade::class,
-> Composer.json:
o   "zizaco/entrust": "5.2.x-dev",
o    "superbalist/laravel-google-cloud-storage": "^1.0",
o    "intervention/image": "^2.3",
-> After all settings update composer for particular branch.

No comments:

Post a Comment