Upload image for image from delphi

I have an API key and read the rare documentation on my site, but still have difficulty making it work, so if anyone has any examples that they could share, that would be great. I don’t need to worry about the video or anything unusual, just a simple download with the returned information will fit my needs.

uses IdHttp; function PostData:string; var url: string; text: string; http: TIDHttp; valid: boolean; param: TStringList; begin http := TIDHttp.Create(nil); http.HandleRedirects := true; http.ReadTimeout := 5000; param := TStringList.create; param.Clear; param.Add('fileupload=c:\image.png'); param.Add('key=MY_API_KEY'); param.Add('tags=tag1,tag2'); valid := true; url := 'http://www.imageshack.us/upload_api.php'; try text := http.Post(url, param); except valid := false; end; if valid then PostData := text else PostData := ''; end; 

thanks. Kevin

+4
source share
1 answer

I pretty much did the same last. thanks tho.

 procedure TForm1.Button1Click(Sender: TObject); var MPData: TIdMultiPartFormDataStream; sResponse: string; begin MPData := TIdMultiPartFormDataStream.Create; MPData.AddFile('fileupload','c:\image.png','image/png'); MPData.AddFormField('tags','testfile,flyasia'); MPData.AddFormField('public','no'); MPData.AddFormField('key','API_KEY_HERE'); sResponse := IdHTTP1.Post('http://www.imageshack.us/upload_api.php', MPData); MPData.Free; Memo1.Text := sResponse; end; 
+1
source

All Articles