This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
4,918 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ yarn-error.log | |
/public/js/app.js | ||
package-lock.json | ||
composer.lock | ||
public/files |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Log; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
class FileController extends Controller | ||
{ | ||
public function uploadFile(Request $request){ | ||
|
||
$data = array(); | ||
|
||
$validator = Validator::make($request->all(), [ | ||
'file' => 'required|mimes:png,jpg,jpeg,pdf|max:2048' | ||
]); | ||
|
||
if ($validator->fails()) { | ||
|
||
$data['success'] = 0; | ||
$data['error'] = $validator->errors()->first('file');// Error response | ||
|
||
}else{ | ||
try { | ||
if($request->file('file')) { | ||
|
||
$file = $request->file('file'); | ||
$filename = time().'_'.$file->getClientOriginalName(); | ||
$filename = hash('sha256', $filename).'.'.$request->file('file')->getClientOriginalExtension(); | ||
// File upload location | ||
$location = 'files'; | ||
|
||
// Upload file | ||
$file->move($location,$filename); | ||
|
||
// Response | ||
$data['success'] = 1; | ||
$data['message'] = 'Uploaded Successfully!'; | ||
$data['link'] = $filename; | ||
|
||
}else{ | ||
// Response | ||
$data['success'] = 0; | ||
$data['message'] = 'File not uploaded.'; | ||
} | ||
} catch (\Exception $e) { | ||
Log::warning('File upload ',$e); | ||
$data['success'] = 0; | ||
$data['message'] = 'File not uploaded.'; | ||
} | ||
|
||
} | ||
|
||
return response()->json($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.