Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] curl jak użyć?
Forum PHP.pl > Forum > Przedszkole
-ktos-
Mam taki błąd: URL file-access is disabled in the server configuration
Provider powiedzial zeby uzyc tej klasy winksmiley.jpg Tylko jak żeby zuploadowac plik z innej strony:>?
Co musze dokladnie wpisać?
  1. <?php
  2.  
  3. class downloader {
  4. var $tempFolder;
  5. var $tempFiles = array();
  6.  
  7. function __destruct () {
  8. foreach ($this->tempFiles as $file) {
  9. unlink($file['temp']);
  10. }
  11. }
  12.  
  13. function __construct ($temp)
  14. {
  15. $this->tempFolder = $temp;
  16. }
  17.  
  18. function get ($url) {
  19. array_unshift($this->tempFiles, array(
  20. 'extension'=> array_pop(explode('.', $url)),
  21. 'original'=> basename($url),
  22. 'temp'=> $this->tempFolder . md5(microtime()),
  23. ));
  24. $ch = curl_init($url);
  25. $fp = fopen($this->tempFiles[0]['temp'], 'w');
  26. curl_setopt($ch, CURLOPT_FILE, $fp);
  27. curl_setopt($ch, CURLOPT_HEADER, 0);
  28. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  29. curl_exec($ch);
  30. curl_close($ch);
  31. fclose($fp);
  32. return $this->tempFiles[0]['temp'];
  33. }
  34.  
  35. function read ($index = 0) {
  36. return file_get_contents($this->tempFiles[$index]['temp']);
  37. }
  38.  
  39. function readArray ($index = 0)
  40. {
  41. return file($this->tempFiles[$index]['temp']);
  42. }
  43.  
  44. function listFiles () {
  45. return $this->tempFiles;
  46. }
  47.  
  48. function save ($path, $index = 0) {
  49. copy($this->tempFiles[$index]['temp'], (is_dir($path) ? $path . $this->tempFiles[$index]['original'] : $path));
  50. }
  51. }
  52.  
  53. $d = new downloader('/home/<username>/<temp folder>');
  54.  
  55. ?>
-ktos-
Chiałem sprobowć oppalić to tak:
  1. <?php
  2. $d = new downloader("home/.trident/xxx/xxx/temp/");
  3. $d->get($_POST[link]);
  4. $d->listFiles();
  5. $d->read();
  6. $d->readArray();
  7. $d->save("miniaturki");
  8. ?>

Ale wywala mi errory:
Kod
Warning: fopen(home/.trident/xxx/xxx/temp/680b885d46039c0ac372a6fc232ef6b6) [function.fopen]: failed to open stream: No such file or directory in /home/.trident/xxx/xxx/funkcje/downloader.class.php on line 24

Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in /home/.trident/xxx/xxx/funkcje/downloader.class.php on line 25

No a dalej tez fclose... itd co zrobiłem zle?
-ktos-
Ja nie używam klas, dlatego proszę o pomoc.. nikt z was nie używa klas żeby wiedział jak to zastosować?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.