I'm using android app to upload images to server, i want to change my php file from uploading images as strings to multipart.
I want to change because i have some problem that i can't upload more than 700KB of images on the server through my android application and i tried everything but still the same problem, someone adviced me to change to multipart because it better
So, could you help me to change this file to fit multipart, please?
<?php
include "connection.php.php";
$sucess = 105;
$fail = 107;
$base = $_POST['sales_images'];
$filename = $_POST['sales_images_names'];
$bedroom = $_POST['bedroom'];
$bathroom = $_POST['bathroom'];
$size = $_POST['size'];
$ref = $_POST['ref'];
$hotDeal = $_POST['hotDeal'];
$sql = "INSERT INTO `sale`(`ref`, `sqm`, `avaliable`, `bedroom`, `bathroom`, `hot_deal`) VALUES ('$ref','$size',1,'$bedroom','$bathroom',$hotDeal)";
$result = mysqli_query($con, $sql);
if ($result === TRUE) {
$last_id = $con->insert_id;
$length = count($base);
for($i = 0; $i < $length; $i++) {
$imageNow = time();
$new_imageFilename = $imageNow . "_" . $filename[$i];
$sql6 = "INSERT INTO `sale_image`(`sale_id`, `img_url`) VALUES ('$last_id','$new_imageFilename')";
$result6 = mysqli_query($con, $sql6);
$binary=base64_decode($base[$i]);
$file = fopen('files/sales/' . $new_imageFilename, 'wb');
fwrite($file, $binary);
fclose($file);
}
echo "New record created successfully. Last inserted ID is: " . $last_id;
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$jsonResult = '{"state":';
if($result){
$jsonResult.= $sucess;
}else {
$jsonResult.= $fail;
}
$jsonResult .="}";
print_r($jsonResult);
?>