Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. -----------------------------1088570827734100011725332862
  2. Content-Disposition: form-data; name="file"; filename="testing-upload.pdf"
  3. Content-Type: application/x-pdf
  4.  
  5. %PDF-1.7
  6. %âãÏÓ
  7. 1 0 obj
  8. <</Type /Catalog
  9. /Outlines 27 0 R
  10. /Pages 4 0 R
  11. >>
  12. endobj
  13. xì} `Eö÷«êéIfLBHBÉÉÎp ÜGÉ®$IDeð@DeYeYd] Ù¨¨è
  14. ^((xàâù~U3 QQ?÷oÿ÷êuÕ«ªW¯^WwÍLbDf ´
  15. Kß9ññuÇló¥
  16. M¿éå{ilØ
  17.  
  18. //PLEASE NOTE I CUT OFF MUCH OF THIS PDF FILE DATA ABOVE
  19.  
  20.  
  21. -----------------------------1088570827734100011725332862
  22. Content-Disposition: form-data; name="ProjectFile"
  23.  
  24. {
  25. "EffectiveOn": "2016-10-26T16:53:56.861Z",
  26. "ProjectId": 1582108
  27. }
  28. -----------------------------1088570827734100011725332862--
  29.  
  30. <?php
  31. $filetoupload = 'C:testing-upload.pdf';
  32. $data = array (
  33. "file" => array("filedata" => '@' . $filetoupload, "filename" => "testing-upload.pdf"),
  34. "ProjectFile" => array(
  35. "EffectiveOn" => "2016-10-14T16:22:38.191Z",
  36. "ProjectId" => "1582108",
  37. ));
  38.  
  39. // json encode data
  40.  
  41. $data_string = json_encode($data);
  42.  
  43. // set up the curl resource
  44. $ch = curl_init();
  45. curl_setopt($ch, CURLOPT_URL, "https://api.example.com");
  46. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  48. curl_setopt($ch, CURLOPT_POST, true);
  49. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  50. curl_setopt($ch, CURLOPT_HEADER, true);
  51. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  52. 'password: 12345',
  53. 'username: demouser' ,
  54. 'Content-Type: multipart/form-data'
  55. ));
  56.  
  57. // execute the request
  58.  
  59. $output = curl_exec($ch);
  60.  
  61. // output data
  62.  
  63. echo($output) . PHP_EOL;
  64.  
  65. // close curl resource to free up system resources
  66. curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement