如何从iOS获取图像路径?

时间:2013-11-23 10:32:45

标签: php ios delphi delphi-xe5 firemonkey-fm3

我正在使用Delphi XE5在服务器上上传文件。我使用php脚本将文件上传到目录中的服务器上,其工作正常。代码是

Delphi代码

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';   }
 }

这在Windows上工作正常,因为我可以使用Topendialog并发送路径 Params.AddFile('file',sfilepath,'image / jpg');

但是如何在iOS中执行此操作? 我想浏览图像(或任何文件)并获取其路径,将其作为参数发送到函数上传(sfilepath:string):string; ?

来自\RAD Studio\12.0\Samples\MobileCodeSnippets\CameraRoll的样本没有给我图像路径

procedure TCameraRollForm.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
 begin
  { Assign the image retrieved from the Photo Library to the TImage component. }
  imgPhotoLibraryImage.Bitmap.Assign(Image);
 end;

有没有办法可以通过iOS在服务器上发送位图?

0 个答案:

没有答案