PHP code example of mar3y / image-upload
1. Go to this page and download the library: Download mar3y/image-upload library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mar3y / image-upload example snippets
use mar3y\ImageUpload\Traits\HasImage;
class YourModel extends Model
{
use HasImage;
protected static $imageAttributes = ['image'];
}
$model = new YourModel();
$model->image = $request->file('image');
$model->save();
$imageUrl = $model->image;
use mar3y\ImageUpload\Helpers\ImageUploadHelper;
$path = ImageUploadHelper::uploadImage($file, 'your-directory');