2010-02-24 41 views
0

我想從iPhone中的照片庫到NSString獲取選定圖像的完整url。如何將庫中選定的圖像存儲到NSString

是否有可能

我的代碼是

NSString * filePath; 
    UIImagePickerController * picker; 
    picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self;  
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    [self presentModalViewController:picker animated:YES]; 

    filePath = /* Here i ant to get the complete url of selected image*/ 

請幫

+0

UIKit不提供此信息。你究竟在努力完成什麼? – Chuck 2010-02-24 07:27:42

+0

在這裏,我想從相機或照片庫將圖像發送到FTP服務器 – Sijith 2010-02-24 07:31:48

回答

1

所以,你想從的UIImagePickerController發送圖像到FTP服務器。在你的委託方法中,取UIImagePickerControllerOriginalImage,這是一個UIImage對象,並調用UIImageJPEGRepresentation()創建一個JPEG文件。然後您可以將JPEG文件發送到您的FTP服務器。

+0

我轉換成圖片JPG格式,但它不是現在發送... 我可以從資源文件夾發送圖像到FTP服務器 我的代碼 文件路徑= [[ NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@「xx」] ofType:@「jpg」]; 在這裏我發送資源文件夾xx.jpg到服務器,工作正常。 如何發送庫文件 – Sijith 2010-02-24 08:04:09

+0

轉換爲jpg後我將如何給url – Sijith 2010-02-24 08:24:05

+0

UIImageJPEGRepresentation爲您提供了一個NSData對象,您可以直接從中獲取數據併發送到您的FTP服務器。無需將其寫入設備上的文件。 – Bearddo 2010-02-24 16:44:58

相關問題