Mit fsockopen Bild an Bildhoster senden (Benötige Hilfe, script konfiguration)

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Mit fsockopen Bild an Bildhoster senden (Benötige Hilfe, script konfiguration)

    Hi,

    ich habe eine $Var (Inhalt ist eine URL http://.....jpg)

    Dieses Bild möchte ich automatisch auf einen Imagehoster laden. (zb. Myimg.de oder imagebanana.com/remoteupload/)
    Also direkt von der webseite auf Imagehoster.
    Ist das mit diesem Script möglich? wenn ja, könnte mir das jemand konfigueren?

    Wäre sehr nett.



    Quellcode

    1. /* sendToHost
    2. * ~~~~~~~~~~
    3. * Params:
    4. * $host - Just the hostname. No http:// or
    5. /path/to/file.html portions
    6. * $method - get or post, case-insensitive
    7. * $path - The /path/to/file.html part
    8. * $data - The query string, without initial question mark
    9. * $useragent - If true, 'MSIE' will be sent as
    10. the User-Agent (optional)
    11. *
    12. * Examples:
    13. * sendToHost('www.google.com','get','/search','q=php_imlib');
    14. * sendToHost('www.example.com','post','/some_script.cgi',
    15. * 'param=First+Param&second=Second+param');
    16. */
    17. function sendToHost($host,$method,$path,$data,$useragent=0)
    18. {
    19. // Supply a default method of GET if the one passed was empty
    20. if (empty($method)) {
    21. $method = 'GET';
    22. }
    23. $method = strtoupper($method);
    24. $fp = fsockopen($host, 80);
    25. if ($method == 'GET') {
    26. $path .= '?' . $data;
    27. }
    28. fputs($fp, "$method $path HTTP/1.1\r\n");
    29. fputs($fp, "Host: $host\r\n");
    30. fputs($fp,"Content-type: application/x-www-form- urlencoded\r\n");
    31. fputs($fp, "Content-length: " . strlen($data) . "\r\n");
    32. if ($useragent) {
    33. fputs($fp, "User-Agent: MSIE\r\n");
    34. }
    35. fputs($fp, "Connection: close\r\n\r\n");
    36. if ($method == 'POST') {
    37. fputs($fp, $data);
    38. }
    39. while (!feof($fp)) {
    40. $buf .= fgets($fp,128);
    41. }
    42. fclose($fp);
    43. return $buf;
    44. }
    Alles anzeigen


    quelle: faqts.com/knowledge_base/view.phtml/aid/12039/fid/51

    gruß
    janni