guard let img = UIImage(named: "aliyun-logo-local") else { return } let imgData = UIImageJPEGRepresentation(img,1) let path = NSSearchPathForDirectorIEsInDomains(.documentDirectory,.userDomainMask,true)[0] let imgPath = "\(path)/\("aliyun-logo-local.png")" NSData(data: imgData!).write(tofile: imgPath,atomically: true) let imgVIEw = UIImageVIEw() vIEw.addSubvIEw(imgVIEw) imgVIEw.frame = CGRect(x: 100,y: 100,wIDth: 100,height: 100) dispatchQueue.global().async(execute: { let fileImage = UIImage.init(contentsOffile: imgPath) dispatchQueue.main.async(execute: { imgVIEw.image = fileImage }) }) //let fileURL = Bundle.main.url(forResource: "aliyun-logo-local",withExtension: "png") let searchURL : URL = URL(fileURLWithPath: imgPath) Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(searchURL,withname: "file") },to: "http://127.0.0.1/upload/upload_file.PHP",enCodingCompletion: { enCodingResult in switch enCodingResult { case .success(let upload,_,_): upload.responseJsON { response in deBUGPrint(response) } case .failure(let enCodingError): print(enCodingError) } })总结
以上是内存溢出为你收集整理的swift3.0图片保存到沙盒-从沙盒读取图片显示-从沙盒上传到服务器全部内容,希望文章能够帮你解决swift3.0图片保存到沙盒-从沙盒读取图片显示-从沙盒上传到服务器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)