I'm sending an image with ajax, but in my .php file never enter to the function. If in the url, in ajax, I just write "xajax_publicar.php" and the log (FB::log("something")) I put this in the php file out of the fuction, this it shows in the console, but in the function, never enter there.
My JS
function GuardarImagen(id)
{
var data = new FormData();
jQuery.each(jQuery('#imagen1')[0].files, function(i, file) {
data.append('imagen-'+i, file);
});
jQuery.ajax({
url: 'xajax_publicar.php/GuardarImagen',
data: data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data){
alert("Datos : " + data);
},
error: function (msg) {
alert("Failed: " + msg.status + ": " + msg.statusText);
}
});
}
This is my PHP File
function GuardarImagen()
{
try
{ //Here i'm doing anything, FB LOG is a log in php
$nombre = $_FILES["imagen-0"]["name"];
FB::log("In te function");
echo "Hola";
}
catch (Exception $e)
{
}
}
I save first a "Publication", then I save Images and call the function in the JS from the same file php with xajax. This is my function that save "Publication".
function Publicar($titulo,$des,$noticia,$torneo,$jornada)
{
try
{
$respuesta = new xajaxResponse();
$funciones = new N_Publicacion();
$objpublicacion = new EN_Publicacion();
$iduser = $_SESSION["iduser"];
if($torneo == 0)
{
$torneo = null;
$jornada = null;
}
$objpublicacion->setTitulo($titulo);
$objpublicacion->setDesc($des);
$objpublicacion->setId_usuario($iduser);
$objpublicacion->setIs_noticia($noticia);
$objpublicacion->setId_torneo($torneo);
$objpublicacion->setId_pro($jornada);
$id_pbl = $funciones->Guardar($objpublicacion);
if($id_pbl!= 0 || $id_pbl!=null)
{
$respuesta->call("GuardarImagen",$id_pbl);
}
else
{
$respuesta->call("Informar","- Ha ocurrido un problema al
publicar. Intente nuevamente.");
}
return $respuesta;
}
catch (Exception $e)
{
}
}