|
| 1 | + |
| 2 | +# 🚀Simple Laravel Encrypt Upload File |
| 3 | +[](https://github.com/irfaardy/raja-ongkir/blob/master/LICENSE) [](https://www.buymeacoffee.com/OBaAofN) |
| 4 | +<h3>🛠️ Installation with Composer </h3> |
| 5 | + |
| 6 | + composer require irfa/raja-ongkir |
| 7 | + |
| 8 | +>You can get Composer [ here]( https://getcomposer.org/download/) |
| 9 | +
|
| 10 | +*** |
| 11 | + |
| 12 | + |
| 13 | +<h2>🛠️ Laravel Setup </h2> |
| 14 | + |
| 15 | +<h3>Add to config/app.php</h3> |
| 16 | + |
| 17 | + 'providers' => [ |
| 18 | + .... |
| 19 | + Irfa\FileSafe\FileSafeServiceProvider::class, |
| 20 | + ]; |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +<h3>Add to config/app.php</h3> |
| 25 | + |
| 26 | + 'aliases' => [ |
| 27 | + .... |
| 28 | + 'FileSafe' => Irfa\FileSafe\Facades\FileSafe::class, |
| 29 | + |
| 30 | + ], |
| 31 | + |
| 32 | + <h2>Publish Vendor</h2> |
| 33 | + |
| 34 | + |
| 35 | + php artisan vendor:publish --tag=file-safe |
| 36 | + |
| 37 | +<h2>Config File</h2> |
| 38 | + |
| 39 | + config/irfa/filesafe.php |
| 40 | + |
| 41 | +<h2>Example store file</h2> |
| 42 | + |
| 43 | + |
| 44 | + <?php |
| 45 | + |
| 46 | + namespace App\Http\Controllers; |
| 47 | + |
| 48 | + use Illuminate\Http\Request; |
| 49 | + use App\Http\Controllers\Controller; |
| 50 | + |
| 51 | + class FileController extends Controller |
| 52 | + { |
| 53 | + |
| 54 | + public function upload_file(Request $request) |
| 55 | + { |
| 56 | + $file = $request->file('file'); |
| 57 | + FileSafe::store($file); |
| 58 | + // |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | +<h2>Example download file</h2> |
| 63 | + |
| 64 | + |
| 65 | + <?php |
| 66 | + |
| 67 | + namespace App\Http\Controllers; |
| 68 | + |
| 69 | + use Illuminate\Http\Request; |
| 70 | + use App\Http\Controllers\Controller; |
| 71 | + |
| 72 | + class FileController extends Controller |
| 73 | + { |
| 74 | + |
| 75 | + public function upload_file(Request $request) |
| 76 | + { |
| 77 | + $file = 'images.jpg'; |
| 78 | + return FileSafe::download($file); |
| 79 | + // |
| 80 | + } |
| 81 | + } |
| 82 | + |
0 commit comments