2011-08-04 28 views
0

我試圖上傳使用ASIFormDataRequestASIFormDataRequest:「沒有文件存在於路徑」,同時完成

ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString: uploadUrl]] autorelease]; 
[request setPostValue:md5sum forKey:@"md5sum"]; 
[request setFile:[NSString stringWithFormat:@"%@", filePath] forKey:@"database"]; 
[request startSynchronous]; 

此記錄一個錯誤文件:當我嘗試的路徑

"No file exists at: file://localhost/Users/thomas/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/36115C00-9352-4CD4-B5C2-C3A1CD6041FF/Documents/foo.sqlite" 

然而在我的瀏覽器中。它立即下載文件,所以文件確實存在。

任何人都有線索?

謝謝!

+0

你怎麼生成文件路徑? – vikingosegundo

回答

0

嘗試使用POSIX路徑:

[request setFile:[[NSURL URLWithString:filePath] path] forKey:@"database"]; 
0

我懷疑這是造成麻煩的%20。嘗試進行反向轉義的filePath變量:

filePath = [filePath stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; 
相關問題