1. Go to this page and download the library: Download sar-cubet/file-upload 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/ */
use SarCubet\FileUpload\Facades\Upload;
$validator = Upload::validateFile($request->file('file'));
if ($validator->fails()) {
return response()->json(['status' => 0, 'errors' => $validator->errors()]);
}
$rules = [
'png' => 'The file types should be any of the following: jpg,png',
'max:5120' => 'The file size should not exceed 5MB'
];
$validator = Upload::validateFile($request->file('file'), $rules);
$scan_file = Upload::scanFile($request->file('file'));
if ($scan_file->isFileInfected()) {
return "This file is found with the malware :" . $scan_file->getMalwareName() . '.';
} else {
return "This file is safe to upload.";
}