1. Go to this page and download the library: Download eduvl/laravel-filekit 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/ */
/** @var \EduVl\FileKit\Contracts\UploadResult $res */
$res = FileKit::images()->upload(
$input, // UploadedFile | string (see below)
filename: null, // optional, e.g. "avatar.jpg"
directory: 'users/42' // subfolder appended to base_dir
);
$res->path; // disk-relative path
$res->url; // public URL or temporary signed route
$res->disk; // disk name
$res->mime; // MIME type
$res->size; // bytes
FileKit::files()->remove($res->path); // true (also true if already missing)
use EduVl\FileKit\Services\FileService;
/** @var FileService $files */
$files = app(FileService::class);
$result = $files->move(
from: 'uploads/tmp/photo.jpg',
toDirectory: 'avatars',
toFilename: 'user-10.jpg',
overwrite: true
);
$result = $files->copy(
from: 'uploads/tmp/photo.jpg',
toDirectory: 'avatars',
toFilename: 'user-10.jpg',
overwrite: true
);
echo $result->path; // avatars/user-10.jpg
echo $result->url; // public url or signed route
---
<a id="signed-urls"></a>
## 🔏 Signed URLs
- **Public** disk → direct `Storage::url($path)`.
- **Private** disk → temporary signed routes:
- `filekit.show` — inline stream
- `filekit.download` — attachment
TTL is `filekit.signed_url_ttl` (minutes).
Manual download URL:
$request->validate([
'file' => ['
namespace App\Services;
use EduVl\FileKit\Services\FileService;
class ExcelService extends FileService {}
namespace EduVl\FileKit\Tests;
use EduVl\FileKit\FileKitServiceProvider;
use Orchestra\Testbench\TestCase as Base;
abstract class TestCase extends Base
{
protected function getPackageProviders($app)
{
return [FileKitServiceProvider::class];
}
protected function defineEnvironment($app)
{
$app['config']->set('filekit.disk', 'public');
}
}
namespace EduVl\FileKit\Tests;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
class RoutesTest extends TestCase
{
public function test_signed_show_serves_file()
{
Storage::fake('public');
Storage::disk('public')->put('uploads/test.txt', 'hello');
$url = URL::temporarySignedRoute('filekit.show', now()->addMinutes(5), [
'path' => 'uploads/test.txt',
]);
$this->get($url)->assertOk()->assertSee('hello');
}
}