我有一個測試和工作的PHP腳本,從數據庫中拉出並返回XML。 我已經使用ASIHTTPRequest成功地發佈了一個POST腳本。 我已經在線尋求幫助,以使其工作。據我所知,所有的代碼都是可靠的。它編譯正確,運行沒有問題,甚至使請求沒有問題。我沒有得到任何錯誤。 由於我已經徹底測試併成功地使用了PHP,我假設這個休息是在iPhone端。iPhone沒有下載文件
我不明白爲什麼它不會將XML文件下載到指定位置。 任何有識之士將不勝感激。
// Create the request
NSURL *url=[[NSURL alloc]initWithString:@"http://localhost:8888/Project/script.php"];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url]retain];
// gather *ALL* data present
if ([txtEmail.text length] > 0)
[request setPostValue:txtEmail.text forKey:@"email"];
if ([txtFName.text length] > 0)
[request setPostValue:txtFName.text forKey:@"firstname"];
if ([txtID.text length] > 0)
[request setPostValue:txtID.text forKey:@"id"];
if ([txtLName.text length] > 0)
[request setPostValue:txtLName.text forKey:@"lastname"];
[request setDidFailSelector:@selector(requestFailed:)];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDownloadDestinationPath:@"/Library/Project/dbInfo.xml"];
[request setDelegate:self];
[request startSynchronous];
[request release];
[url release];
,你能否告訴我們setDownloadDestinationPath方法的定義。您是否有權將文件讀取/寫入您的下載指定位置? –
setDownloadDestinationPath是ASIHTTPRequest的一部分。這不是關於權利。我無法讓它與 即 的直接響應一起工作NSString * response = [request responseString]; – anijam
在端口8888上iPhone上是否運行服務器?在這種情況下'localhost'將會是電話本身... – ceejayoz