Advertisement
Guest User

Untitled

a guest
Jun 10th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. if(!isset($argv[1])){
  4. echo "FIle nor provided\n";
  5. exit(-1);
  6. }
  7.  
  8. $name=$argv[1];
  9. $data=file_get_contents($name);
  10.  
  11. $data=[
  12. 'data'=>base64_encode($data),
  13. 'name'=>basename($name)
  14. ];
  15.  
  16. $data=json_encode($data);
  17.  
  18. $ch = curl_init();
  19. curl_setopt($ch, CURLOPT_URL,"http://localhost/base64Upload/");
  20. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  21. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  22. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  25. 'Content-Type: application/json',
  26. 'Content-Length: ' . strlen($data))
  27. );
  28.  
  29. $result = curl_exec($ch);
  30. $response_complete=curl_getinfo($ch);
  31. var_dump($response_complete);
  32. echo "\n";
  33. echo ($result);
  34. echo "\n";
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement