Skip to content

Instantly share code, notes, and snippets.

@paulocoutinhox
Last active December 26, 2015 14:59
Show Gist options
  • Save paulocoutinhox/7169135 to your computer and use it in GitHub Desktop.
Save paulocoutinhox/7169135 to your computer and use it in GitHub Desktop.
1 - Exemplo de como enviar arquivo em base64 pro servidor.2 - Crie um script shell com este conteúdo.3 - Execute ele com o comando:sh nome-do-script.sh4 - Parabéns!
<?php
echo("Baixando imagem...\n");
exec("curl -o /tmp/image_test.jpg http://zerohora.rbsdirect.com.br/imagesrc/15045099.jpg?w=620");
echo("Convertendo em base64...\n");
$data = file_get_contents('/tmp/image_test.jpg');
$base64 = base64_encode($data);
echo("Enviando...\n");
$url = 'http://site.com/services/serviceGallery/upload';
$fields = array(
'source' => 'web',
'image' => $base64,
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
var_dump($result);
//close connection
curl_close($ch);
echo("Finalizado...\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment