I've tested with an example i found in the archives.

'Method not allowed' is returned.

What am I doing wrong ?

Paul




function TBandwidthCheckForm.Upload:boolean;
const
  LR= #13#10;
var
  Buf : String;
  FileToSend : TMemoryStream;
  Boundary, FName: string;
begin
  result:= true;
  FName:= '20k.jpg';
  TestClient.URL:= UrlBandWidhUpload;
  try
    with TestClient do begin
      Boundary := '-----------------------------7cf29e12c04';
      ContentTypePost := 'multipart/form-data; boundary=' + 
copy(Boundary,3,length(Boundary));

      Buf := Boundary + LR + 'Content-Disposition: form-data; name="upfile"; 
filename="' + FName + '"'
                  + LR + 'Content-Type: image/jpeg' + LR + LR;

      SendStream:= TMemoryStream.Create;
      try
        SendStream.Write(Buf[1], Length(Buf));
        FileToSend := TMemoryStream.Create;
        FileToSend.LoadFromFile(TestFile);
        FileToSend.SaveToStream(SendStream);
        FileToSend.Free;

        Buf := ConCat(buf,Boundary+'--');
        SendStream.Write(Buf[1], Length(Buf));
        SendStream.Seek(0, soFromBeginning);
        FFileSize:= SendStream.Size;
        SetThreadPriority(Application.Handle, 
THREAD_PRIORITY_TIME_CRITICAL);
        Post;
        ElapsedTimeMs:= CalcMilliSeconds(StartTime);
        SetThreadPriority(Application.Handle, THREAD_PRIORITY_NORMAL );
      finally
        TestClient.RcvdStream.Free;
        TestClient.RcvdStream := nil;
        TestClient.SendStream.Free;
        TestClient.SendStream := nil;
      end;
    end;
  except;
    result:= false;
  exit;
  end;
end;

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to