PHP code example of pfrug / file-upload

1. Go to this page and download the library: Download pfrug/file-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/ */

    

pfrug / file-upload example snippets


// config/app.php
'providers' => [
    ...
    Pfrug\FileUpload\FileUploadServiceProvider::class,
];



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Pfrug\FileUpload\Traits\HasImageUploads;

class Post extends Model
{
    use HasImageUploads;

    protected $uploadableImages = [
        'image',
        'thumb'
    ];


public function store(Request $request)
{    
    // ... you code here, try-catch validate etc..
    Post::create($request->all());
    ...


public function update(Request $request, Post $post)
    // ... you code here, try-catch, validate data, etc..
    $post->fill($request->all());
    $post->save();


$post->title = $request->title ;
$post->image = $request->file('image');
$post->save();


    @        'item' => $post,
            'field' => 'image',
            'cant_delete' => true
        ])
sh
php artisan vendor:publish --tag="fileupload-assets" --provider="Pfrug\FileUpload\FileUploadServiceProvider"
php artisan vendor:publish --tag="fileupload-lang" --provider="Pfrug\FileUpload\FileUploadServiceProvider"
php artisan vendor:publish --tag="fileupload-views" --provider="Pfrug\FileUpload\FileUploadServiceProvider"