Jump to content

Luciano Veneziano

Members
  • Content Count

    3
  • Joined

  • Last visited

Posts posted by Luciano Veneziano


  1. Funziona perfettamente:

     

    function httpsUpload(URL : string; fname : String ) : String;
    var
      LRequest: THTTPClient;
      LFormData: TMultipartFormData;
      LResponse: TStringStream;
    begin
      LRequest := THTTPClient.Create;
      LFormData := TMultipartFormData.Create();
      LResponse := TStringStream.Create;
      try
        LFormData.AddField('json', '{"id":1,"user":"Luciano"}');   //optional
        LFormData.AddFile('file', fname);
        LRequest.Post(URL, LFormData, LResponse);
        Result := LResponse.DataString;
      finally
        LFormData.Free;
        LResponse.Free;
        LRequest.Free;
      end;
    end;

     

    phpfile

     

    <?php
    include_once("local/setup.php");
    $where = $_FILES["file"]["name"];
    if(move_uploaded_file($_FILES["file"]["tmp_name"], $where))
    {
      echo "OK\r\n";
    }
    else
    {
      echo "ERR\r\n";
    }
    print_r($_FILES);
    ?>


  2. Hi everyone I have a PHP file that uploads images to me.
    I should send with HTTPS and post the parameters from Delphi like this.

    <form action = "UPLOAD.PHP" enctype = "multipart / form-data">
    <input type = "file" name = "upfile" required />
    <input type = "submit" value = "Upload" />
    </form>

    Unfortunately I'm not very good, I was able to make calls in https and post, but I could not set up idHTTP correctly

    Has anyone already encountered this problem?

    Thanks to all.

×