Config:1. Server 1
PHP, Default UTF-8
Send Message:
POST http://www.server2site.com/upload HTTP/1.0\r\n
Host: server2site.com\r\n
Content-Type: multipart/form-data; boundary=1BEF0A57BE110FD467A\r\n
Content-Length: 491\r\n
\r\n data of file
------1BEF0A57BE110FD467A\r\n
Content-Disposition: form-data; name="datafile"; filename="myimage.jpg"\r\n
Content-Type: text/plain\r\n
Content-Transfer-Encoding: binary\r\n
\r\n
------1BEF0A57BE110FD467A--\r\n
2. Server 2
RTC HTTP Server
Upload Function (QuickStart\BrowserUpload)
procedure TUploaderDM.UploadProviderDataReceived(Sender: TRtcConnection);
var ADir:String;
begin
with TRtcDataServer(Sender) do
begin
if Request.Method='GET' then
begin
Write('<html><body><form enctype="multipart/form-data" method="post">');
Write('Type some text, if you like:<br>');
Write('<input type="text" name="textline" size="30"><br>');
Write('Please specify a file to upload:<br>');
Write('<input type="file" name="datafile" size="40"><br>');
Write('<input type="submit" value="Send">');
Write('</form></body></html>');
end
else
begin
Request.Params.AddText(Read);
if Request.Complete then
begin
Write('<html><body>');
if Request.Params['datafile']<>'' then
begin
ADir:=GetServerDir+'Files\';
if not DirectoryExists(ADir) then
CreateDir(ADir);
if Request.Params.GetFile('datafile', ADir+
ExtractFileName(Request.Params['datafile'])) then
Write('File "'+Request.Params.Value['datafile']+'" was uploaded to server.')
else
Write('Error receiving File "'+Request.Params.Value['datafile']+'".');
end
else
Write('No file uploaded (DataFile parameter empty).');
Write('</body></html>');
end;
end;
end;
end;
Results:Upload with Browser to Server2 nice work!
Upload from Server1 not work.
Params of Request included only: name, filename
IsFile name and filename = false
Sending file included by Request, but not parsed.
How to accept file from Server1?
Thank you.