Se venligst mit svar til spørgsmålet:
Gem flere billeder i mysql php fra Android, men kun ét billede bliver indsat
Rediger:
I dit PHP-script overskriver du billedoverførslen, fordi du bruger den samme uploadsti for begge billeder.
Du skal sikre dig, at $path
værdien er unik .
Prøv dette script:
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
define('HOST','hostname');
define('USER','username');
define('PASS','password');
define('DB','dbname');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$path = "uploads/".uniqid().".png";
$path1 = "uploads/".uniqid().".png";
$actualpath = "http://oursite/PhotoUploadWithText/$path";
$actualpath1 = "http://oursite/PhotoUploadWithText/$path1";
$sql = "INSERT INTO uploads (image,image1,name) VALUES ('$actualpath','$actualpath1','$name')";
if(mysqli_query($con,$sql)){
file_put_contents($path,base64_decode($image));
file_put_contents($path1,base64_decode($image1));
echo "Successfully Uploaded";
}
mysqli_close($con);
}else{
echo "Error";
}