SHARE
TWEET

stack_help

pabloducato Dec 26th, 2018 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. header('Access-Control-Allow-Origin: *');
  4. define('PUBLIC_KEY', 'e646664649fb49e8ac9f');
  5.  
  6. $tempPath = $_FILES['file']['tmp_name'];
  7. $actualName = $_FILES['file']['name'];
  8.  
  9. $actualPath = dirname(__FILE__)."\\temp\\".$actualName;
  10. move_uploaded_file($tempPath, $actualPath);
  11.  
  12. $ch = curl_init();
  13.  
  14. $post = [
  15.     'UPLOADCARE_PUB_KEY'=>PUBLIC_KEY,
  16.     'UPLOADCARE_STORE'=>1,
  17.     'file'=> curl_file_create($actualPath)
  18. ];
  19.  
  20. curl_setopt($ch, CURLOPT_URL, 'https://upload.uploadcare.com/base/');
  21. curl_setopt($ch, CURLOPT_POST, 1);
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  23. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  24.  
  25. $response = curl_exec($ch);
  26. //var_dump($response);
  27. echo($response);
  28. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top