Im working on Delphi XE5 for uploading a file on a server. Im using a php script to upload the file on the server in a directory,its working fine. the code is
Delphi code
Function Upload(sfilepath : string) : string;
var
Params: TIdMultipartFormDataStream;
Response: TStringStream;
http: TIdHttp;
begin
try
http := TIDHttp.Create(nil);
http.HandleRedirects := true;
http.ReadTimeout := 5000;
http.Request.ContentType:='multipart/form-data';
Params := TIdMultipartFormDataStream.Create;
Response := TStringStream.Create;
try
Params.AddFile('file',sfilepath , 'image/jpg'); // 'C:\Sc.png'
http.Post('http://xxx.xxx.x.xx:8080/mages/php/uploadFilesToserverDirectory.php', Params, Response);
result:=Response.DataString;
finally
Params.Free;
Response.Free;
http.Free;
end;
except
on e: Exception do
ShowMessage(e.Message);
end;
end;
php code
< ?php
if (isset($_FILES['file']) && $_FILES['file']['error'] == UPLOAD_ERR_OK)
{
$target = 'uploads/'. time();
$result = move_uploaded_file($_FILES['file']['tmp_name'], $target);
if (!$result) {
echo 'Cannot copy'; }
}
This works fine on windows as i can use Topendialog and send the path Params.AddFile('file',sfilepath , 'image/jpg');
but how to do this in iOS? i want to browse the image(or any file) and get its path to send it as an argument in Function Upload(sfilepath : string) : string; ?
The samples from \RAD Studio\12.0\Samples\MobileCodeSnippets\CameraRoll
doesnt give me the image path
procedure TCameraRollForm.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
begin
{ Assign the image retrieved from the Photo Library to the TImage component. }
imgPhotoLibraryImage.Bitmap.Assign(Image);
end;
Is there a way i can send the bitmap on the server via iOS ?