fork download
  1. <?php
  2.  
  3.  
  4. // URL del archivo a descargar
  5. $file_url = 'https://c...content-available-to-author-only...a.cu/pluginfile.php/1/theme_enlightlite/logo/1679431194/logotipo-etecsa-version-horizontal-%20copia.png';
  6. $file_path = 'hqdefault.png';
  7.  
  8. // Descargar el archivo
  9. $ch = curl_init($file_url);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11. $response = curl_exec($ch);
  12. $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  13.  
  14. if ($http_code == 200) {
  15. file_put_contents($file_path, $response);
  16. } else {
  17. echo 'Error al descargar el archivo: ' . $http_code;
  18. exit();
  19. }
  20.  
  21. // URL del servidor de destino
  22. $target_url = 'https://c...content-available-to-author-only...a.cu/repository/repository_ajax.php?action=upload';
  23.  
  24. $post = array(
  25. 'repo_upload_file' => new CURLFile($file_path, 'image/jpeg', 'hqdefault.png'),
  26. 'title' => 'hq.jpg',
  27. 'author' => 'Francisco Gómez',
  28. 'license' => 'allrightsreserved',
  29. 'itemid' => '375367234',
  30. 'repo_id' => '4',
  31. 'p' => '',
  32. 'page' => '',
  33. 'env' => 'filemanager',
  34. 'sesskey' => 'REBmRIYCgF',
  35. 'client_id' => '66eacb76e9c9e',
  36. 'maxbytes' => '67108864',
  37. 'areamaxbytes' => '104857600',
  38. 'ctx_id' => '4146',
  39. 'savepath' => '/'
  40. );
  41.  
  42. $ch = curl_init();
  43. curl_setopt($ch, CURLOPT_URL, $target_url);
  44. curl_setopt($ch, CURLOPT_POST, 1);
  45. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  46. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47.  
  48. $response = curl_exec($ch);
  49. if ($response === false) {
  50. echo 'Error: ' . curl_error($ch);
  51. } else {
  52. echo $response;
  53. }
  54.  
  55.  
  56.  
  57. ?>
  58.  
  59.  
  60.  
Success #stdin #stdout 0.04s 26488KB
stdin
Standard input is empty
stdout
Error al descargar el archivo: 0