Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $binary_data = base64_decode($_POST['image']);
- $boundary = uniqid();
- $content = "--$boundary\r\n";
- $content .= "content-disposition: form-data; name=\"photo\"; filename=\"my-photo.png\"\r\n";
- $content .= "Content-Type: image/png\r\n";
- $content .= "Content-Transfer-Encoding: binary\r\n";
- $content .= "\r\n";
- $content .= "$binary_data\r\n";
- $content .= "--$boundary--\r\n";
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header'=> "Content-type: multipart/form-data, boundary=$boundary\r\nContent-Length: " . strlen($content),
- 'content' => $content
- )
- ));
- echo(file_get_contents($_POST['serverURL'], false, $context));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment