Problem with uploading images in jpg format from android to mysql server, just upload png format

0

Good evening I have a problem happens that I am saving the images in my database from my android in a longblob column so then what happens esque saves me only PNG formats, but I when selecting images from my android app in jpg format Well, does not it work for me? Does anyone know the problem? Here I leave my code q would be the webseries that if I work with PNG but with JPG nothing.

  $host_name = "localhost";
  $database = "base_olx";
   $user = "root";
  $password = "";

  $con = mysqli_connect($host_name,$user,$password,$database);

  $json = json_decode(file_get_contents("php://input"),true);


 //$nombre = $json["nombre"];
  $nombre = $json["listaNombres"];
  $listaImagen = $json["listaImagen"];
  $elIdProdInmueble = $json["idProdInmueble"];




   $respuesta = array();


   if(isset($listaImagen)){

      if(is_array($listaImagen)){
       $i = 0;
       $u = 1;
       $f = "foto";
       foreach($listaImagen as $imagen){



           $na = $nombre[$i];
           $f = $f.$u;
           $ruta = "../fotos/".$na;
           $imagen = addslashes($imagen);
           $insertarEnGaleria = "INSERT INTO 'galeria'('url', 
   'id_prod_inmu','imagen', 'ruta') VALUES 
   ('$f','$elIdProdInmueble','$imagen','$ruta')";


           $decodedImagen = base64_decode($imagen);
           $return = file_put_contents("../fotos/".$na,$decodedImagen);
           $i++;


           //$insertarEnGaleria = "INSERT INTO 'galeria'('url', 
   'id_prod_inmu','imagen', 'ruta') VALUES 
   ('$f','$elIdProdInmueble','$decodedImagen','$ruta')";
            $f = "foto";
            $u++;
            mysqli_query($con,$insertarEnGaleria);

       }

        $respuesta["ok"] = "Imagenes agregadas con exitos";
   }


   header('Content-Type: application/json');
   echo  json_encode( $respuesta);
  }else{
    $respuesta["ok"] = "Hubo un error fatal";
    header('Content-Type: application/json');
   echo  json_encode( $respuesta);
   }

Thank you friends, I hope you can help me.

    
asked by David Garcia 31.10.2018 в 05:52
source

0 answers