pl: PHP und PUT

Beitrag lesen

Untenstehender Code funktioniert. Request PHP:

$host = "example";
$port = 80;
$file = "d:/tmp/red.gif";
$content = file_get_contents($file);
$url = sprintf("%s?filename=%s", "/getpost.php", urlencode(basename($file)));

$len = strlen($content);
$socket = fsockopen($host, $port);
fputs($socket,"PUT $url HTTP/1.0\n");
fputs($socket,"Content-Length: $len\n");
fputs($socket, "Host: $host\n\n");
fputs($socket, $content);

# Response ausgeben
while(!feof($socket)) {
    echo fgets($socket, 128);
}

Serverseitig PHP:

header("Content-Type: text/plain");
echo "Anzahl Bytes gesendet: ", $_SERVER{'CONTENT_LENGTH'}, "\n\n";

print_r($_GET);
$body = file_get_contents("php://input");
echo "BODY:\n", $body;


# Datei probeweise anlegen
$filename = $_GET['filename'];
$fp = fopen("d:/tmp/upload/$filename", "wb");
fputs($fp, $body);

(Ohne Fehlerbehandlung, ohne Auth.Baisc)

PS: Alternative RequestMethod: fputs($socket,"Zitrone $url HTTP/1.0\n");

0 60

Post2Host via SSL

TS
  • php
  • tls
  • webserver
  1. 0
    dedlfix
    1. 0
      TS
      1. 0
        dedlfix
  2. 1
    MudGuard
    1. 0

      Post2Host via SSL, Fehler gefunden

      TS
      1. 0
        pl
      2. 0
        dedlfix
        1. 0
          TS
          1. 0
            dedlfix
            1. 0
              TS
              1. 0
                dedlfix
          2. 0
            pl
            1. 1
              dedlfix
              1. -1
                pl
                1. 0
                  dedlfix
                  1. 0
                    TS
                    1. 0
                      dedlfix
                    2. 0
                      1unitedpower
          3. -1
            pl
      3. 0
        1unitedpower
        1. 0
          TS
        2. -1
          pl
  3. 0
    pl
  4. 0

    Funktion für Post2Host via SSL, Zwischenstand 2019-05-30

    TS
    1. 0
      Mitleser
      1. 0
        TS
        1. 0
          Mitleser
          1. 0
            TS
      2. 1
        1unitedpower
        1. 0
          Mitleser
        2. 0
          TS
          1. 1
            1unitedpower
            1. 0
              TS
      3. 0
        pl
        1. 0

          PHP und PUT

          TS
          1. 0
            dedlfix
          2. 0
            pl
            1. 0
              dedlfix
              1. 0
                pl
                1. 0
                  dedlfix
              2. 0
                TS
                1. 0
                  dedlfix
                  1. 0
                    TS
                    1. 1
                      dedlfix
                    2. 1
                      1unitedpower
          3. 0
            pl
            1. 0
              pl
              1. 0
                TS
                1. 0
                  pl
                  1. 0
                    TS
                    1. 0
                      pl
                      1. 0
                        dedlfix
                        1. 0
                          pl
                  2. 0
                    JürgenB
                    1. 0
                      pl
        2. 0
          Mitleser
          1. 0
            pl
            1. 1
              Mitleser
    2. 1
      dedlfix