Reputation: 43
I need to upload a file to the site rghost.net:
procedure TForm1.Button1Click(Sender: TObject);
var
HTTP: THTTPSendEx;
Data: TMultipartFormDataStream;
sHTML: string; //Received HTML code from web
upload_url, fireld_name: string;
begin
upload_url:='http://kaon.rghost.ru/files';
fireld_name:='file';
if OpenDialog1.Execute then
begin
HTTP:=THTTPSEndEx.Create;
HTTP.UserAgent:='Mozilla/5.0 (Windows; I; Windows NT 5.1; ru; rv:1.9.2.13) '+
'Gecko/20100101 Firefox/4.0';
Data:=TMultipartFormDataStream.Create;
try
//Data.AddFile(fireld_name, OpenDialog1.FileName);
Data.AddFile(fireld_name, OpenDialog1.Filename);
Data.DataEnd;
if HTTP.Post(upload_url,Data,sHTML) then
begin
end;
finally
FreeAndNil(HTTP);
FreeAndNil(Data);
end;
Memo1.Text := sHTML;
ShellExecute(Handle, 'open', 'page.html', nil, nil, SW_SHOWNORMAL);
end;
end;
The program should return a reference to a file, but it returns:
500 - your request could not be processed at the moment, because of an error on the server.
What is wrong?
Upvotes: 2
Views: 779
Reputation: 84550
What's wrong is exactly what the message says: an error on the server.
This can mean one of two things. Either the problem's not in your code and there's nothing you can do about it, or the problem is in your code and the website is returning the wrong error message. Either way, you need to contact the folks behind rghost to get any idea of what's really going on. 500-level errors are things that have to be dealt with on their end, not yours.
Upvotes: 2