I am sending an image and associated data from my Android app to my laravel php backend
final MediaType JPEG = MediaType.parse("image/JPEG; charset=utf-8");
RequestBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("filename", image.getFilename())
.addFormDataPart("hash", image.getHash())
.addFormDataPart("job_id", Integer.toString(image.getJobId()))
.addFormDataPart("team", Integer.toString(image.getTeam()))
.addFormDataPart("type", image.getType())
.addFormDataPart("image_file", image.getFilename(), RequestBody.create(JPEG, imagefile)).build();
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
Response response = client.newCall(request).execute();
The backend php looks like this
public function updateJobImage(array $request_data){
var_dump($request_data);
$toInsertImage = [
'job_id' => $request_data['job_id'],
'type' => $request_data['type'],
'filename' => $request_data['filename'],
'team' => $request_data['team'],
'hash' => $request_data['hash']
];
$filepath = '/schedule_images/' . $request_data['hash'] . "/" . $request_data['filename'];
Storage::disk('s3_upload')->put($filepath, file_get_contents($request_data['image_file']));
I can get all the job_id/type/filename/team/hash data perfectly fine but the image_file is an empty array. How do I handle getting the image file on the php side