Я пытаюсь отправить данные с изображением для профиля и получаю эту ошибку:
Неверный тип ресурса: массив
данные:
Array ( [name] => staff [userId] => 1 [phoneNumber] => 88888888888888888 [postalCode] => 123123 [city] => asdas [state] => asdasd [country] => asdasd [skills] => Array ( [0] => 8 [1] => 10 ) [image] => Illuminate\Http\UploadedFile Object ( [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] => [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => Screenshot from 2020-04-16 13-37-59.png [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => image/png [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0 [hashName:protected] => [pathName:SplFileInfo:private] => /tmp/phpt76Li7 [fileName:SplFileInfo:private] => phpt76Li7 ) [dob] => 2010-04-14 [staff_id] => 2 [gender] => male [first_name] => norma [last_name] => fatohi [token] => eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Ijc1MWJmZTZkMDM0YTk3MTI1OGQwNGQwYTM4NjYxNTUwY2Q5OWRkMDUzY2NjMTE0NTUzODNhMjViZGNmNTBiMTUwZmQyN2IxYzEwMDhlOWFlIn0.eyJhdWQiOiIxIiwianRpIjoiNzUxYmZlNmQwMzRhOTcxMjU4ZDA0ZDBhMzg2NjE1NTBjZDk5ZGQwNTNjY2MxMTQ1NTM4M2EyNWJkY2Y1MGIxNTBmZDI3YjFjMTAwOGU5YWUiLCJpYXQiOjE1ODgwNTAyMTAsIm5iZiI6MTU4ODA1MDIxMCwiZXhwIjoxNjE5NTg2MjEwLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.VR6HwGg_4hTywTMofzdPfkobLgoDxOmzk1p2S7rhSFNrTfU1zhitX3jm4Ny6B5GeS-lxZI6o4vzQ2zvpZ9AFfzwsm6pc1AjsRT7cORBakBCQ42npX3wU8lLFysGygnNarjVUz7SIdaqaXmmT9o-uEYAjXTiS5lfgCEmeWL_04DI_0OVWD5D01r8w0vSZxt09H_jzZGHqT2U_E9aA1ulc6_PYvPapQjcEd3UFR7HVVRJoKI-HMpFJ2OToQVAJw-0Zj0Lzdz9pS3WFOOs8GWNT8rLk4iJQWkMrVWa-ec7HYrcOpCapccoI5MsO_jEdkUTuGgItC5L90cbHnFPffXkYDJTaxAZ8sindAepMFL61gxkUA-b5z6sL3ER-8aorKVUZQsXEDEMLh0CLh-wNsDrb3yOp8aRJxj-HW7bnKjXJTYgp1a6KdOJ_irX4dAHUcQNMrT3yI2TMsQc3qv7djk1PBUrz4sfNhGkFJW8bPr7dlh0DD9GHBHlz2B2DCeMCr0BtK_qpBx47uXtcChWt5PeykGllbgrMxXxXgctlv-3CK_JDZmt40EAkJ5dSKtSAmLxvEu6bFj_1aw6t_XrxEbzE-F--1dIlju82b39G7NTw-Ep0hr6OU1tYxBAHVNQmv7gAWe5H9Tdus9zOvwla-rbnejgX3gXjPFRmz9Lvu69Gfrg )
Как вы можете видеть, IMG загружает из внешнего интерфейса, и мой API также отлично работает на почтальоне, он загружает данные, но с жадностью он не работает
function staff_profile_update(Request $request){
$data = $request->all();
$request_data = ['name'=>$data['name'],'userId'=>$data['id'],'phoneNumber'=>$data['phoneNumber'],
'postalCode'=>$data['postalCode'],'city'=>$data['city'],'state'=>$data['state'],'country'=>$data['country'],
'skills'=>$data['skills'],'image'=>$data['image'],'dob'=>$data['dob'],'staff_id'=>$data['staff_id'],'gender'=>$data['gender'],'first_name'=>$data['first_name'],'last_name'=>$data['last_name'],
'token'=>$data['token']];
$response_data = $this->apiService->multipartApiRequest("api/edit_staff_profile", $request_data,'post');
if($response_data['status']== 1){
return redirect('staff_profile')->with('data','profile updated successfully');
}
else{
return redirect('staff_profile_edit')->with('data','Something went wrong');
}
}
multipart api services:
public function multipartApiRequest($url, $data = array(),$requestType='') {
$url = $this->base_url . $url;
$client = new Client();
$headers = [
'Authorization' => 'Bearer '.$data['token'],
];
$image_path = $data['image']->getPathname();
$image_mime = $data['image']->getmimeType();
$image_org = $data['image']->getClientOriginalName();
$response = $client->request($requestType,$url,
[
'multipart' => [
[
'name' => 'userId',
'contents' => $data['userId'],
],
[
'name' => 'staff_id',
'contents' => $data['staff_id'],
],
[
'name' => 'phoneNumber',
'contents' => $data['phoneNumber'],
],
[
'name' => 'postalCode',
'contents' => $data['postalCode'],
],
[
'name' => 'city',
'contents' => $data['city'],
],
[
'name' => 'state',
'contents' => $data['state'],
],
[
'name' => 'country',
'contents' => $data['country'],
],
[
'name' => 'skills',
'contents' => $data['skills'],
],
[
'name' => 'gender',
'contents' => $data['gender'],
],
[
'name' => 'dob',
'contents' => $data['dob'],
],
[
'name' => 'first_name',
'contents' => $data['first_name'],
],
[
'name' => 'last_name',
'contents' => $data['last_name'],
],
],
"headers"=>$headers
]);
$contents = json_decode($response->getBody()->getContents(), true);
return $contents;
}
нет все кажется нормально, но все еще та же ошибка Неверный тип ресурса: массив
проверка данных API почтальона работает: