So I have made an api in laravel. Here is the code in
ApiController.php
This is the api function
public function apiFileReceive(Request $request){
$file=$request->file('filename');
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$tempPath = $file->getRealPath();
$fileSize = $file->getSize();
$mimeType = $file->getMimeType();
return response(['filename'=>$filename, 'extension'=>$extension,'fileSize'=>$fileSize,'mimetype'=>$mimeType,'file'=>$request->file('filename')],200);
}
HomeController.php
This is the code from where I am calling the api.
public function sendFileToApi(Request $request){
if($request->admission_import!=null){
$file = $request->file('admission_import');
$filename = $file->getClientOriginalName();
$response=Http::attach('filename',$request->file('admission_import'),$filename)->post('localhost/address_of_api');
$val=$response->json();
dd($val);
}
}
The problem is when I am trying to access the file in ApiController's apiFileReceive() function. I am unable to access the file.
dd($val) shows this

The file is null. Can somebody tell me what I'm missing.