开发者

NSData to file PHP

开发者 https://www.devze.com 2023-04-06 21:06 出处:网络
I have NSData that I am \'POST\'ing to a PHP file on my site, from that NSData, I am writing it to a file. However, the file\'s contents are the string of NSData (range of letters and numbers) rather

I have NSData that I am 'POST'ing to a PHP file on my site, from that NSData, I am writing it to a file. However, the file's contents are the string of NSData (range of letters and numbers) rather than the parsed data. How can I parse the NSData to a string in PHP and then write the contents of that string to a file?

Here is my code so far:

$filename = $_POST['username'] . "_iCal_" . $newID . ".ics";
$File = $upload_path . $filename; 
$Handle = fopen($File, 'w');
$Data = urldecode($_POST['ical']);
$Data = str_replace (" ", "", $Data);
fwrite($Handle, $Data) or die("s");
fclose($Handle) or die("s");


[NSKeyedArchiver archivedDataWithRootObject:event] //event is an NSObj-- Subclass with NSCoding etc... implemented
开发者_如何学PythonASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:MPiCalUpload_URL]];
[request setTimeOutSeconds:MPiCalRetriever_timeout];
[request setPostValue:_username forKey:@"username"];
[request setPostValue:data forKey:@"ical"];


Consider passing the data as a Base64 string. Search SO for "NSData Base64", you'll find plenty of examples. Then on the PHP side, use base64_decode() to get the bytes back.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号