First Commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
|
||||
public function uploadThis(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'file' => 'required',
|
||||
]);
|
||||
|
||||
$file = $request->file('file');
|
||||
$fileContent = $file->get();
|
||||
// echo 'File Name: '.$file->getClientOriginalName();
|
||||
// echo 'File Extension: '.$file->getClientOriginalExtension();
|
||||
// echo 'File Real Path: '.$file->getRealPath();
|
||||
// echo 'File Size: '.$file->getSize();
|
||||
// echo 'File Mime Type: '.$file->getMimeType();
|
||||
|
||||
// Encrypt File
|
||||
$encryptedContent = encrypt($fileContent);
|
||||
\Storage::put('file.dat', $encryptedContent);
|
||||
}
|
||||
|
||||
public function downloadThis(Request $request)
|
||||
{
|
||||
// Decrypt File
|
||||
$encryptedContent = \Storage::get('file.dat');
|
||||
$decryptedContent = decrypt($encryptedContent);
|
||||
|
||||
return response()->streamDownload(function() use ($decryptedContent) {
|
||||
echo $decryptedContent;
|
||||
}, 'file.jpg');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user