相关疑难解决方法(0)

ios使用HTTP POST上传图像和文本

谢谢阅读.

我是iOS新手,我正在尝试使用multi-part form encodingiOS 上传图片和文字.

curl等值是这样的:curl -F "param1=value1" -F "param2=@testimage.jpg" "http://some.ip.address:5000/upload"

curl上面的命令返回预期的正确响应JSON.

问题: 我一直收到HTTP 400请求,这意味着我在编写HTTP POST Body时出错了.

我做了什么: 作为一些参考,我尝试了 Flickr API iOS应用"POST尺寸太大了!" 目标C:如何使用HTTP POST上传图像和文本?.但是,我一直在获得HTTP 400.

我尝试了ASIHttpRequest但在那里有一个不同的问题(回调永远不会被调用).但是,我没有进一步调查,因为我听说开发人员已停止支持该库:http://allseeing-i.com/ [request_release] ;

有人可以帮帮我吗?

curl file-upload http-post image-uploading ios

96
推荐指数
4
解决办法
14万
查看次数

ios 9 - xcode 7 - SFSafariViewController - 图像上传 - 相机黑屏

我正在使用SFSafariViewController,并遇到以下问题:向用户显示上传图像按钮,单击时设备正确显示多个选项,其中一个是相机.当用户选择摄像机时,它会加载摄像机,但屏幕为黑色,操作按钮显示为灰色.但是,如果用户选择库,则会正确上载所选图像.

我确认该应用已启用相机权限.

我试着实现这里这里找到的修复,但无济于事.

其他人遇到这个问题?

码:

import UIKit
import SafariServices

class ViewController: UIViewController, SFSafariViewControllerDelegate
{
    private var urlString:String = "https://example.com"

    override func viewDidLoad()
    {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewDidAppear(animated: Bool)
    {
        super.viewDidAppear(animated)

        let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)

        svc.delegate = self

        self.presentViewController(svc, animated: true, completion: nil)
    }

    func safariViewControllerDidFinish(controller: SFSafariViewController) {
        super.dismissViewControllerAnimated(true, completion: nil)
    }

    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any …
Run Code Online (Sandbox Code Playgroud)

xcode camera ios swift sfsafariviewcontroller

13
推荐指数
1
解决办法
2339
查看次数

iOS 8.0 UIWebView文件输入崩溃我的应用程序

更新到iOS 8.0后,单击"选择文件"按钮(HTML文件输入),然后单击"拍摄照片或视频"/"选择现有"会导致我的应用程序崩溃.

自iOS 6以来,此功能一直运行良好,但在iOS 8.0中,文件输入功能完全被破坏!

有没有其他人遇到UIWebView应用程序相同的问题?

iphone objective-c uiwebview ios

7
推荐指数
1
解决办法
6681
查看次数

单击按钮时,UIWebView打开相机和图像

我目前正在将webApp作为应用程序包装起来.在Web应用程序中,有一个按钮,当自动点击时会询问您是否要转到存储图像的摄像头,选择后将为您上传图像.在手机浏览器的网络应用程序中,这可以按预期工作.

现在我已将webApp包装在UIWebView中,此功能不再有效.实际上,当选择上述任一选项时,它似乎会关闭UIWebview.有谁知道通过UIWebView使这个工作的过程是什么.

我必须得到许可吗?或者更多的是在单击按钮时检测HTML并从UIWebView处理它.

按钮上的HTML看起来像这样.

   <input type="file" required id="file" name="file" accept="image/*" multiple>
Run Code Online (Sandbox Code Playgroud)

新增代码

WebViewController.h

 #import <UIKit/UIKit.h>

 @interface WebViewController : UIViewController <UIWebViewDelegate,UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
    UIViewController *viewController;
}
Run Code Online (Sandbox Code Playgroud)

........

WebViewController.m

 #import "WebViewController.h"
 #import <AssetsLibrary/AssetsLibrary.h>
 #import "AppDelegate.h"
 @end
 @implementation WebViewController


 - (void)viewDidLoad
 {
      [super viewDidLoad];
      viewController = [[UIViewController alloc] init];   
      NSString *fullURL = self.mainURL; // get this from defualts - have removed code for this




NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_viewWeb loadRequest:requestObj];

ALAssetsLibrary *lib = [[ALAssetsLibrary alloc] init];

[lib …
Run Code Online (Sandbox Code Playgroud)

html objective-c uiwebview ios

3
推荐指数
1
解决办法
6852
查看次数