I have created a validation system to check if the uploaded files are secured and virus-free, I'm using ClamAV for that purpose.
At first I was testing locally on my MACOS using XAMPP but I kept getting the below error
Sunspikes \ ClamavValidator \ ClamavValidatorException ClamAV scanner client failed with error "Socket operation failed: Connection refused (SOCKET_ECONNREFUSED)" Previous exceptions Socket operation failed: Connection refused (SOCKET_ECONNREFUSED) (61)
I've uploaded the files to my cPanel/CentOS server thought that clamav is limited on MacOS unlike CentOS however I got the same error.
The code used as follow:
public function upload(KycUploadRequest $request) {
$this->validate($request, [
'address' => 'clamav',
'document' => 'clamav'
]
);
//
$user = Auth::user();
$data = $request->all();
if($file = $request->file('address')) {
$name = time() . $file->getClientOriginalName();
$file->move('images', $name);
$data['address'] = $name;
}
if($file2 = $request->file('document')) {
$name = time() . $file2->getClientOriginalName();
$file2->move('images', $name);
$data['document'] = $name;
}
$kyc = new KycVerification();
$kyc->user_id = $user->id;
$kyc->address = $data['address'];
$kyc->document = $data['document'];
$kyc->status = 1;
$kyc->save();
Session::flash('status', 'Your documents were sent for verification, you will receive a notification status about your request!');
return redirect()->back();
}
I use this package: https://github.com/sunspikes/clamav-validator
I'm stuck for hours with no solution, any help please. Note I'm using laravel 5.8 both on xampp/macos and cpanel/centos.