Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/09/2010, 06:41
userman
 
Fecha de Ingreso: diciembre-2006
Mensajes: 173
Antigüedad: 18 años, 1 mes
Puntos: 2
Por que no me funciona

Hola,

el script que tengo me funciona en varios servidores, pero en el mio en concreto no me funciona y me gustaria saber porque, si me falta alguna configuracion especial en el servidor o algo (el soporte cURL esta instalado y activado)

el error que me da es: (el archivo foto.jpg existe en el mismo directorio del script)

[email protected];type=image/jpeg

el script es el siguiente:

Código PHP:
<?php
ini_set
("display_errors","On");

function 
getFileType($filename) {
            
$fparts explode(".",trim($filename));
            
$stype strtolower($fparts[count($fparts)-1]);
            
$type = ((($stype=="jpg") || ($stype=="jpeg"))?"jpeg":$stype);
            return 
"image/".$type;
}

$ch curl_init("http://www.imageshack.us/upload_api.php");

$post['xml']='yes';
$filename "foto.jpg";
$type getFileType($filename);
$post['fileupload']='@'.$filename.';type='.$type;

$post['rembar']="1";
$post['login']="3a0987afa783b69fc1f7058ca503ea80";
$post['cookie']="3a0987afa783b69fc1f7058ca503ea80";


curl_setopt($chCURLOPT_POSTtrue);
curl_setopt($chCURLOPT_HEADERfalse);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_TIMEOUT300);
curl_setopt($chCURLOPT_POSTFIELDS$post);
curl_setopt($chCURLOPT_HTTPHEADER, array('Expect: '));
$result curl_exec($ch);
curl_close($ch);
if (
strpos($result'<'.'?xml version="1.0" encoding="iso-8859-1"?>') === false) {
        echo 
'failed';
        
print_r($result);
} else {
       
print_r($result);
}
echo 
'@'.$filename.';type='.$type;
?>