作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用以下代码在 FTP 服务器上上传 PNG 文件。
NSURL *ftpURL=[NSURL URLWithString:@"ftp://username:password@localhost"];
NSMutableURLRequest *urlRequest=[[NSMutableURLRequest alloc] initWithURL:ftpURL];
[urlRequest setHTTPMethod:@"POST"];
[postData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"imageUrl\"; filename=\"dummy.png\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"Content-Type: image/png\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"Content-Transfer-Encoding: binary\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
UIImage *img=[UIImage imageNamed:@"a.png"];
NSMutableData *postData=[[NSMutableData alloc] init];
NSData *data=UIImagePNGRepresentation(img);
[postData appendData:data];
[urlRequest setHTTPBody:postData];
[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:YES];
我没有收到任何 NSURL 连接,比如连接失败或请求身份验证。只是,我收到的回电是
-(void) connectionDidFinishLoading:(NSURLConnection *)connection
我不确定 NSURLConnection 是否支持 ftp 上传。我不打算使用 CFFTPStream 来实现它。任何人都可以纠正我的方法吗?
最佳答案
我在 BlackRacoon 上取得了很好的成功.
关于objective-c - NSURLConnection FTP文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13101737/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!