Skip to main content

Posts

Showing posts from February, 2020

Upload Image and PDF file on Server with Android and PHP Using Retrofit

PHP File <?php  $con=new MySQLi("localhost","","","");  if($_SERVER['REQUEST_METHOD']=='POST'){     $image = $_POST['img'];     $name = $_POST['name'];     $sql ="SELECT * from img";     $res = mysqli_query($con,$sql);     $id = 0;     while($row = mysqli_fetch_array($res)){             $id = $row['id'];     }     $path = "upload/$id.pdf";     $actualpath = "URL/$path";     $sql = "INSERT INTO img (img,name) VALUES ('$actualpath','$name')";     if(mysqli_query($con,$sql)){         file_put_contents($path,base64_decode($image));         echo "Successfully Uploaded";     }     mysqli_close($con); }else{     echo "Error"; } public interface ApiConfig { @Multipart @POST( "uploadpdf.php" ) Call<ServerRespons...