我正在上傳從iPhone應用程序到給定的PHP頁面的MP3文件。爲此,我找到了ASIFormDataRequest類。現在,我在我的應用程序做了一段代碼,像這樣:從iPhone應用程序上傳mp3到我的(基於PHP)Web服務器
NSLog(@"fastBackwardButtonLoosened - sending the stuff");
NSString *theUrl = @"MyServerURL";//Sorry not showing this:)
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:theUrl]];
[request setFile:[soundFileURL absoluteString] forKey:@"mainfile"];
[request startSynchronous];
NSLog(@"The request was sent!!");
但我無法弄清楚如何把我的NSURL至極點到MP3這一要求內。我已經嘗試了以上,但無法找到任何指向正確方向的東西。任何想法?
接收請求的代碼是像這樣:
$SafeFile = $HTTP_POST_FILES['mainfile']['name'];
$uploaddir = "uploads/";
$path = $uploaddir.$SafeFile;
if($mainfile != none){ //AS LONG AS A FILE WAS SELECTED...
if(copy($HTTP_POST_FILES['mainfile']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED...
//Good
} else {
//Bad
}
}
任何幫助,將不勝感激:)
是否將mp3上傳到iphone上的本地文件? – JosephH
是的,它會位於iphone本身。 – Manuel