Code snippets
Code snippets
Copy-ready answers to everyday coding questions, each with a short explanation. Laravel, PHP, JavaScript, SQL, Bash and more.
2 snippets tagged #files · Show all
PHP
November 2, 2026
Laravel file upload: validate, store and get the URL
Validates an uploaded image, stores it on the public disk and builds its URL. Run php artisan storage:link once so the public disk is web-accessible.
<?php
use Illuminate\Support\Facades\Storage;
Bash
October 17, 2026
Linux find files by name, size or age and delete them safely
find searches by name, size and modified time. Run it without -delete first to preview what matches.
find . -name "*.log" # by name
find /var/log -type f -size +100M # larger than 100 MB
find . -type f -mtime +30 # older than 30 days
find . -name "*.tmp" -type f -print # preview first