PHP code example of pucci / laravel-helpers
1. Go to this page and download the library: Download pucci/laravel-helpers 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/ */
pucci / laravel-helpers example snippets
use FileSaver;
$uploadedFile = $request->file('documento');
$path = FileSaver::save(
$uploadedFile,
'uploads',
'public',
null,
true
);
$localPath = storage_path('app/example.txt');
$path = FileSaver::save(
$localPath,
'backups',
'local',
'example_backup.txt',
false
);
$deleted = FileSaver::delete('uploads/nome-file.txt', 'public');
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use FileSaver;
class FileTestController extends Controller
{
public function upload(Request $request)
{
$path = FileSaver::save(
$request->file('documento'),
'uploads',
'public',
null,
true
);
return back()->with('success', "File salvato in: $path");
}
public function delete(Request $request)
{
$deleted = FileSaver::delete($request->input('file_path'));
return back()->with('success', $deleted ? "File eliminato" : "File non trovato");
}
}
Route::post('/file-test/upload', [FileTestController::class, 'upload'])->name('file.upload');
Route::post('/file-test/delete', [FileTestController::class, 'delete'])->name('file.delete');