Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/08/2011, 23:56
Avatar de salbatore
salbatore
 
Fecha de Ingreso: abril-2007
Ubicación: Springfield
Mensajes: 1.567
Antigüedad: 17 años, 1 mes
Puntos: 19
Respuesta: Subir imagen a imageshack

Hola de nuevo...

Aqui va el codigo:

Código PHP:
Ver original
  1. $data['key'] = "clave";
  2.    
  3.     $data['public'] = "yes";
  4.     $data['public'] = "yes";
  5.     $data['email']      = "email";
  6.     $data['a_username']      = "user";
  7.     $data['a_password']      = "password";
  8.     $data['rembar']     = "yes";
  9.     $data['xml'] = "yes";
  10.     //new name:
  11.        
  12.     $new_name=carpetatemporal.''.$usuario.'_'.date("Y-m-d_G-i-s").'_'.uniqid().'.jpg';
  13.     echo $_FILES['image']['tmp_name'].'<hr/>';
  14.     if (move_uploaded_file($_FILES['image']['tmp_name'],$new_name))
  15.         {
  16.             $data['fileupload'] ='@'.$new_name.'';
  17.             echo $new_name.'<hr/>';
  18.  
  19.         }
  20.     else
  21.         {
  22.             echo "El archivo no se pudo cargar en el servidor.<hr/>";
  23.         }
  24.     $curl = curl_init();
  25.     curl_setopt($curl, CURLOPT_URL, 'http://www.imageshack.us/upload_api.php');
  26.     curl_setopt($curl, CURLOPT_POST, true);
  27.     curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/4.0");
  28.     curl_setopt ( $curl , CURL_HTTPHEADER , "Content-type: ".$_FILES['image']['type']."" );
  29.     curl_setopt($curl, CURLOPT_HEADER, false);
  30.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  31.     /*curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);*/
  32.     curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  33.     $result = curl_exec($curl);
  34.      $error = curl_error($curl);
  35.     echo  $result;
  36.     echo $error;
  37.     curl_close($curl);

Esta muy pero que muy poco trabajado... pero tengo sueño...

Hasta pronto!!