tayyabshahzad1's avatar

Uploading Via PostMan

Hi, I am making an API in my project, In this Project, there are two tables one for user and the second is usersphotos.

On normal form request, my code is working fine and I am able to upload user all images, but when I use postman it is saving users all data in user table but unable to add photos into userphotos table.

My Code Is Below,



foreach($propertyPhotos as $propertyPhoto){
    $trimed_name = preg_replace('/\s+/', '', $propertyPhoto->getClientOriginalName());
    $propertyImage= new PropertyPhoto;
    $propertyPhoto->storeAs('public/image/',$trimed_name);
    $propertyImage->property_id =  $property->id;
    $propertyImage->photo = $trimed_name;
    $propertyImage->save();
}

0 likes
2 replies
panthro's avatar

How are you sending the image in POSTMAN?

Should be under form data.

Please or to participate in this conversation.