1. Go to this page and download the library: Download ibekzod/uploader 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/ */
ibekzod / uploader example snippets
use IBekzod\Uploader\Uploader;
use IBekzod\Uploader\Models\Upload;
use App\Models\Post;
$upload = Uploader::uploadAttachment($request->file('attachment'))->getUpload();
//Let's assume we have Post model with image_id column or file_id whatever name you can write
$post = Post::create([
'title'=>'Title',
'body'=>'Body',
'image_id'=>$upload->id //unsigned big integer is preferred
]);
//This is optional if you want to find
$upload->relation='post';//or simply Post::class
$upload->relation_id=$post->id;
$upload->save();
//By this way you can get all post images
$allPostImages=Upload::where('relation', 'post')->get();
//Or related first post image
$postImage=Upload::where('relation', 'post')->where('relation_id', $post->id)->first();
//You are free to design your structure by using Upload