swift 4 调试完alamofire以后,不能用request 40C

Xcode 10.1, Swift 4.2 。
AlamoFire 调试完成以后,输入Alamofire.request 只显示AlamoFireVersionNumber。我不知道哪个地方调错了,我这上不了GitHub, AlamoFire也是别人帮我下的,实在找不到方法,哪位高手帮我解决一下这问题。

Csdn user default icon
swift3.0 alamofire 单例

用alamofire写的借口类,我需不需要把alamofire单例了,因为我用的是alamofire.request 是不是直接调用类方法了

Swift Alamofire调用java的图片上传http接口

1.java的http接口有两个参数,一个字符串,一个MultipartFile图片文件 接口代码如下: ``` @ResponseBody @RequestMapping(value="/uploadUserImg/{userName}",method=RequestMethod.POST) public Map<String,Object> uploadUserImg(@RequestParam("userImg") MultipartFile imgFile,@PathVariable("userName") String userName) { } 或者 @ResponseBody @RequestMapping(value="/uploadUserImg",method=RequestMethod.POST) public Map<String,Object> uploadUserImg(@RequestParam("userImg") MultipartFile imgFile,@RequestParam"userName") String userName) { } ``` 请问怎样用Swift Alamofire编写调用方法,我在接口里打断点,下面的方法调用总是进不去接口 ``` class FileAPI { static func uploadImage(userImage: Data, _ reqCallBack: @escaping(Bool, JSON?, APIError?) -> Void) { let maxByte = 1024 * 1024 * 2 if userImage.count > maxByte { reqCallBack(false, nil, APIError.uploadFileFail(msg: "图片大于2M,无法上传")) return } let url = "" Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(userImage, withName: "userImg") }, to: url, method: .post, headers: ["Content-Type": "application/x-www-form-urlencoded"], encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.responseJSON { response in let json = JSON(response.data!) reqCallBack(true, json, nil) } case .failure(let error): reqCallBack(false, nil, APIError.unknow) print(error) } } ) } ``` 错误提示: [Request]: POST [Response]: <NSHTTPURLResponse: 0x6000026df840> { URL: } { Status Code: 400, Headers { Connection = ( close ); "Content-Language" = ( en ); "Content-Length" = ( 1123 ); "Content-Type" = ( "text/html;charset=utf-8" ); Date = ( "Tue, 04 Jun 2019 05:34:50 GMT" ); Server = ( "Apache-Coyote/1.1" ); } } [Data]: 1123 bytes [Result]: FAILURE: responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(error: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})) [Timeline]: Timeline: { "Request Start Time": 581319290.237, "Initial Response Time": 581319290.455, "Request Completed Time": 581319290.524, "Serialization Completed Time": 581319290.547, "Latency": 0.218 secs, "Request Duration": 0.287 secs, "Serialization Duration": 0.023 secs, "Total Duration": 0.310 secs } (lldb)

Swift使用Alamofire调用C# Webservice的问题

同事已经使用安卓调用成功,传一个JSON给Webservice,并返回一个JSON 已经将webservice架设到外网服务器上了[]( "临时webservice"),大神帮忙调用一下看看,我写的代码如下,但一直报错: var wcfurlString = "" Alamofire.request(Method.POST, wcfurlString, parameters: ["userId" : id , "pwd" : psw], encoding: ParameterEncoding.JSON).responseJSON { ( request, response, JSON, error) in println(request) println(response) println(JSON) println(error) } } 输出信息如下: <NSMutableURLRequest: 0x7f9cec87ccc0> { URL: } Optional(<NSHTTPURLResponse: 0x7f9cea4c2130> { URL: } { status code: 500, headers { "Cache-Control" = private; "Content-Length" = 3297; "Content-Type" = "text/html; charset=utf-8"; Date = "Tue, 18 Aug 2015 02:56:33 GMT"; Server = "Microsoft-IIS/7.5"; "X-AspNet-Version" = "4.0.30319"; "X-Powered-By" = "ASP.NET"; } }) nil Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x7f9cec9a2d20 {NSDebugDescription=Invalid value around character 0.})




<div class="post-text" itemprop="text"> <p>I receive an error when trying to send parameters via POST request to my server via Alamofire.</p> <pre><code> // Create payload to be submitted to the server let userReference = appDelegate.userReference let parameters : [String : AnyObject] = [ "userReference": userReference, "pushToken": pushToken, "installationReference": "" ] Server().sendPOSTRequestToServer(endpoint: "devices", parameters: parameters) { (response) -&gt; Void in let responseCode = response["code"] switch(responseCode) { case 201: completionHandler(response: response) break default: break } } } func sendPOSTRequestToServer(endpoint endpoint: String, parameters: [String:AnyObject], completionHandler: (response: JSON) -&gt; Void) { Alamofire.request(.POST, self.requestUrl + endpoint, parameters: parameters, encoding: .JSON).responseJSON { (response) -&gt; Void in switch response.result { case .Success: completionHandler(response: JSON(response.result.value!)) case .Failure(let error): print("POST REQUEST ERROR - \(endpoint) - \(error.localizedDescription)") print("=== REQUEST INFORMATION ===") print("Status Code: \(response.response!.statusCode)") print("Request URL: \(response.request!.URLString)") print("Request Payload: \(parameters)") print("===") } } } </code></pre> <p>The error I receive is:</p> <pre><code>&gt; POST REQUEST ERROR - devices - The data couldn’t be read because it &gt; isn’t in the correct format. &gt; === REQUEST INFORMATION === Status Code: 200 Request URL: http://SERVERIP/v1/devices Request Payload: ["pushToken": &gt; PUSHTOKEN, &gt; "userReference": res_hq9gpcgap09joe, "installationReference": ABC] &gt; === </code></pre> <p>I formated the parameters array correctly I would guess. Where is this error coming from?</p> <p>The Server code:</p> <pre><code>// Store new Device public function store(Request $request) { // Get payload from request $bodyContent = json_decode($request-&gt;getContent(), true); $installationReference = $bodyContent["installationReference"]; $devicesFound = DeviceHelper::searchForExistingDevice($installationReference); if ($devicesFound == 0) { // If no device is found, create unique id for device as installation id and execute command to register device. $newInstallationReference = "ins_" . CustomHelper::createUniqueId(14); $registerDeviceCommand = new RegisterDeviceCommand($bodyContent, $newInstallationReference); $this-&gt;commandBus-&gt;execute($registerDeviceCommand); $this-&gt;respondCreated("Device was created."); return json_encode(array("code" =&gt; $this-&gt;statusCode, "installationReference" =&gt; $newInstallationReference), JSON_NUMERIC_CHECK); } else { $this-&gt;setStatusCode(404)-&gt;respondWithError("Device already exists"); return json_encode(array("code" =&gt; $this-&gt;statusCode), JSON_NUMERIC_CHECK); } } </code></pre> </div>

为什么我的php json_encode不能在alamofire中使用.responseJSON进行序列化?

<div class="post-text" itemprop="text"> <p>I'm having some trouble with serialization on a JSON response on my iOS app from my server, its a PHP back-end. My app sends a post request with the appropriate parameters, validates them, puts the results in an array, and encodes it in. Now that's not the problem, code works fine. However, its the link between them. Look at the PHP code below.</p> <pre class="lang-php prettyprint-override"><code>echo json_encode($array) </code></pre> <p>Now coming to xcode, I'm using alamofire to send the request as seen in the code below</p> <pre class="lang-swift prettyprint-override"><code>Alamofire.request(URL_USER_REGISTER, method: .post, parameters: parameters).responseString { response in print(response) } } </code></pre> <p>As you can see its in .responseString because I apparently if I use .responseJSON it throws a code=3480 error and I want to get specific data from my own response JSON. I tried other ways to fix this online, but they all choose the .responseString option.</p> <p>Why is this happening? Are the JSON types incompatible? Is there a secret to this?</p> <p>I just want to get specific data from my JSON response such as "message" and its not possible when i get a string... Any help is appreciated!</p> <p>I'm using Alamofire 4.3</p> </div>

在Swift 4中发出HTTP POST请求

<div class="post-text" itemprop="text"> <p>I´m trying to send data to a PHP file on my server using <code>URLSession</code>. This seems to fail though, since no data is received on the server. While running the app, I get this console print:</p> <pre><code>2018-01-09 20:56:10.942359+0100 EinsatzPush[12182:8624757] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert 2018-01-09 20:56:10.942857+0100 EinsatzPush[12182:8624757] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert 2018-01-09 20:56:10.943028+0100 EinsatzPush[12182:8624757] TIC Read Status [1:0x1c0173680]: 1:57 2018-01-09 20:56:10.943187+0100 EinsatzPush[12182:8624757] TIC Read Status [1:0x1c0173680]: 1:57 2018-01-09 20:56:10.943278+0100 EinsatzPush[12182:8624757] TIC Read Status [1:0x1c0173680]: 1:57 2018-01-09 20:56:10.943923+0100 EinsatzPush[12182:8624757] [BoringSSL] Function boringssl_session_errorlog: line 2871 [boringssl_session_read] SSL_ERROR_ZERO_RETURN(6): operation failed because the connection was cleanly shut down with a close_notify alert </code></pre> <p>This is the code I´m using:</p> <pre><code>let url = URL(string: "https://my-server.com/update.php") let session = URLSession.shared let request = NSMutableURLRequest(url: url as! URL) request.httpMethod = "POST" let paramString = "username=user&amp;token=token" request.httpBody = paramString.data(using: String.Encoding.utf8) let task = session.dataTask(with: request as URLRequest) { ( data, response, error) in guard let _:NSData = data as NSData?, let _:URLResponse = response, error == nil else { print("error") return } if let dataString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue) { print(dataString) } } task.resume() </code></pre> <p>I´d be very happy if anyone here could help me get this fixed. Thanks!</p> </div>


swift 2.0 xcode 7.1.1 pod 0.390 然后下载到项目,但是只能下载Alamofire2.0的 gitHub上Alamofire已经到3.1.1了

Xcode10.1 安装swift5.0真机运行错误

电脑比较老mac最高升级到10.13.6,Xcode最高升级到10.1,不支持swift5. 从苹果那下载了swift5.0。 ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586921811_273170.png) ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586921917_409559.png) 创建的是swift项目 模拟器运行正常,使用真机就报错 ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586921988_927623.png) ![图片说明](https://img-ask.csdn.net/upload/202004/15/1586922003_792712.png) 网上看到一些方法比如在other linker flags 加上$(inherited)没有用 library search paths 加上$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)同样不行 求解救!!!

Swift以纵向模式捕获照片并上传到服务器 - 上传的图像显示方向错误

<div class="post-text" itemprop="text"> <p>If I take a picture with my iPhone in portrait mode, and send this picture with alamofire to server -&gt; the image will stored perfectly. If I try to use this picture in html, the orientation is wrong. The image is rotated -90 degrees. I tried to save the image in jpg, and png format, but I have the same issue both.</p> <pre><code>Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(imageData, withName: "image", fileName: "image.png", mimeType: "image/png") }, to: SERVER_URL, encodingCompletion: { encodingResult in switch encodingResult {..... </code></pre> <p>On the server side:</p> <pre><code>&lt;?php ..... $response['error'] = "NULL"; $filename = uniqid() . ".png"; move_uploaded_file($_FILES['image']['tmp_name'], "image/" . $filename) ...... ?&gt; </code></pre> <p>I think there will be 2 different solution, but I could not find the correct way. 1) I have to change the orientation on my iPhone device somehow 2) I have to change the orientation on the server side before I upload to the server.</p> <p>(I don't want to make the solution on the client side)</p> </div>


<div class="post-text" itemprop="text"> <p>I'm trying to make an api call to submit some data using <code>Alamofire</code> (version 4.0). I think the request has succeed. But the trouble i'm having is that when making the call I get a response from the server that 0 byte FAILURE.</p> <p>I have tried many of the solutions currently on StackOverflow and cannot find a solution. Thanks for your help.</p> <p><strong>Here is my <code>Postman</code> setup:</strong></p> <p><a href="https://i.stack.imgur.com/6Lnp1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Lnp1.jpg" alt="enter image description here"></a></p> <p><strong>My Swift code:</strong></p> <pre><code>import UIKit import Alamofire class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let headers: HTTPHeaders = [ "content-type": "x-www-form-urlencoded"] Alamofire.request("myurl.php?method=GET_RECENT", headers: headers).responseJSON { response in debugPrint(response) print(response.request) // original URL request print(response.response) // HTTP URL response print(response.data) // server data print(response.result) // result of response serialization if let JSON = response.result.value { print("JSON: \(JSON)") } } } } </code></pre> <p><strong>The error I'm getting is:</strong></p> <blockquote> <p>[Request]: myurl.php?method=GET_RECENT [Response]: { URL: myurl.php?method=GET_RECENT } { status code: 200, headers { "Cache-Control" = "max-age=0"; Connection = "Keep-Alive"; "Content-Length" = 0; "Content-Type" = "text/html; charset=UTF-8"; Date = "Sun, 01 Jan 2017 11:41:31 GMT"; Expires = "Sun, 01 Jan 2017 11:41:31 GMT"; "Keep-Alive" = "timeout=7, max=100"; Server = "Apache/2.2.15 (CentOS)"; "X-Powered-By" = "PHP/5.6.25"; } } <strong>[Data]: 0 bytes [Result]: FAILURE:</strong> responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength) [Timeline]: Timeline: { "Request Start Time": 504963459.698, "Initial Response Time": 504963459.821, "Request Completed Time": 504963459.821, "Serialization Completed Time": 504963459.821, "Latency": 0.123 secs, "Request Duration": 0.123 secs, "Serialization Duration": 0.001 secs, "Total Duration": 0.124 secs } Optional(myurl.php?method=GET_RECENT) Optional( { URL: myurl.php?method=GET_RECENT } { status code: 200, headers { "Cache-Control" = "max-age=0"; Connection = "Keep-Alive"; "Content-Length" = 0; "Content-Type" = "text/html; charset=UTF-8"; Date = "Sun, 01 Jan 2017 11:41:31 GMT"; Expires = "Sun, 01 Jan 2017 11:41:31 GMT"; "Keep-Alive" = "timeout=7, max=100"; Server = "Apache/2.2.15 (CentOS)"; "X-Powered-By" = "PHP/5.6.25"; } }) <strong>Optional(0 bytes) FAILURE</strong></p> </blockquote> </div>

Alamofire POST请求PHP脚本没有值

<div class="post-text" itemprop="text"> <p>I have a problem with a POST request in Alamofire. If I try to make a POST Request, it seems that the PHP script doesn't get the values. This is my POST Request:</p> <pre><code>func userRegistration(){ let url = "http://offlineshopper.sunpowr.de/register.php" let parameters: [String:String] = ["nickname":RegisterTexts.nickname, "password":RegisterTexts.password, "email":RegisterTexts.email] print(parameters) Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON{ response in if((response.result.value) != nil){ let swiftyJsonVar = JSON(response.result.value!) print("Das kommt dabei raus: \(swiftyJsonVar)") } } } </code></pre> <p>The parameters Dictionary print this: ["nickname": "Test", "password": "Test", "email": "Test"]</p> <p>So I think this is right.</p> <p>This here is my PHP Script:</p> <pre><code>&lt;?php include("mysql_connect.php"); if(isset($_POST['nickname'])){ $nickname = $_POST['nickname']; } if(isset($_POST['password'])){ $password = $_POST['password']; } if(isset($_POST['email'])){ $email = $_POST['email']; } //Check if nickname is already used $select = "SELECT `nickname` FROM `User` WHERE nickname = '$nickname'"; $result = mysqli_query($link, $select); if (!$result){ $returnArray["message"] = "Fehler in der Datenbank!"; json_encode($returnArray); } if (mysqli_num_rows($result) != 0){ $returnArray["message"] = "Nickname bereits vorhanden!"; json_encode($returnArray); } //Add new User to the database $sql = "INSERT INTO User (nickname, password, email) VALUES ('$nickname', '$password', '$email')"; if(mysqli_query($link, $sql)){ $returnArray["message"] = "Erfolgreich registriert!"; echo json_encode($returnArray); } else{ mysqli_error($link); $returnArray["message"] = "Fehler!"; echo json_encode($returnArray); } mysqli_close($link) ?&gt; </code></pre> <p>I get the response "Erfolgreich registriert" in my App so everything should work fine. I also get new datasets in my database. The problem is that only the id is set in the database, which is auto increment. The other fields are empty so the POST variables are never saved in the database.. Any ideas what I'm doing wrong here?</p> <p>EDIT: It's working now, just switching</p> <pre><code>Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON </code></pre> <p>with</p> <pre><code>Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding.httpBody).responseJSON </code></pre> </div>

swift 创建container时出现错误不知道怎么解决

我输入了这样一条命令: swift -A -U mytry:swift -K 'AtVBbaot5mYXChq9UDTmM4fNzQ3SPu3yAzAB1UMs' post a_ewn_tyr 我想通过这一条命令创建一个名为a_ewn_tyr的container,但是报了如下的错误: Container PUT failed: 400 Bad Request InvalidLocationConstraint Failed Transaction ID: tx000000000000000000004-005b1f2e59-1bdc5-default IP和端口我都检查过,是可以正常使用的,但是提示我非法的地址约束就不知道为什么了,然后我完全不知道怎么解决,如能帮助解决将十分感谢

swift 2.0json中文乱码怎么转换

调用Alamofire.request返回的json是这样的: { "\U4f1a\U5458ID" = 40; "\U5173\U5361ID" = 4; "\U540d\U79f0" = "\U65b0\U6982\U5ff5\U82f1\U8bed\U7b2c\U4e00\U518c"; "\U5c01\U9762" = "2015528174214.png"; "\U603b\U5173\U6570" = 72; "\U603b\U5206" = 0; "\U6392\U540d" = 1404; "\U6717\U8bfb\U4eba\U6570" = 6350; "\U6e38\U620fID" = 11; "\U72b6\U6001" = 1; "\U7c7b\U522bID" = 1; "\U8349\U8393" = 312; } 要怎么处理 是swift 2.0

Alamofire - 字符0周围的值无效

<div class="post-text" itemprop="text"> <p>I am getting below error by using Alamofire. Wondering what is wrong with my server code. If I use responseString, I get a result showing the whole php code including <code>&lt;?php</code> and <code>?&gt;</code>. Any suggestions?</p> <pre><code>Alamofire.request("http://domain/test.php", method: .post, parameters: [:], encoding: URLEncoding.default, headers: [:]).responseJSON { (response) in switch response.result { case .success(_): print(response.result.value) case .failure(let error): print(error) } } </code></pre> <p>Error</p> <pre><code>responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.})) </code></pre> <p>Server Code (test.php)</p> <pre><code>&lt;?php $essay = array( array("Intro" =&gt; array("intro") ), array("section" =&gt; array("a", "b", "c", "d", "e", "f", "g" ) ), array("End" =&gt; array("a", "b") ) ); echo json_encode($essay); ?&gt; </code></pre> <p>If I use responseString, I get </p> <pre><code>Optional("&lt;?php $essay = array( \tarray(\"Intro\" =&gt; \t\tarray( \t\t\t\"intro\" \t\t\t) \t\t), \tarray(\"1\" =&gt; \t\tarray( \t\t\t\"a\", \t\t\t\"b\", \t\t\t\"c\", \t\t\t\"d\", \t\t\t\"e\", \t\t\t\"f\", \t\t\t\"g\" \t\t\t) \t\t), \tarray(\"End\" =&gt; \t\tarray(\t \t\t\t\"a\", \t\t\t\"b\" \t\t\t) \t\t) \t); echo json_encode($essay); ?&gt; ") </code></pre> <p>If I try to run the code in my server, I get</p> <pre><code>php test.php [{"Intro":["intro"]},{"1":["a","b","c","d","e","f","g"]},{"End":["a","b"]}] </code></pre> </div>


本人android程序员一名,最近闲来无事打算研究一下swift来开发ios,正好公司有一个小应用实践,但是必须使用DSBridge,作为新人的我,完全不知道怎么导入DSBridge的包,查看网上的文档,都是pod "dsbrdige",试了一下,完全不可以,有哪位大神赐教一下吗

Alamofire花费了太多时间上传6张图片,其中一些参数几乎总计大约2 mb

<div class="post-text" itemprop="text"> <p>PHP side code:</p> <pre><code>&lt;?php include('dbConnect.php'); if($_SERVER['REQUEST_METHOD']=='POST'){ //Getting values $customer_email = $_POST['email']; $age = $_POST['age']; $city = $_POST['city']; $gender = $_POST['gender']; $issue_title = $_POST['issue_title']; $issue_desc = $_POST['issue']; $relation = $_POST['relation']; $image1 = $_POST['image1']; $image2 = $_POST['image2']; $image3 = $_POST['image3']; $image4 = $_POST['image4']; $image5 = $_POST['image5']; $today_date = date('Y-m-d H:i:s'); $case_id = rand(1,100000); $path1 = null; $path2 = null; $path3 = null; $path4 = null; $path5 = null; $path6 = null; function checkfive() { global $image5,$path5; if($image5=="No Image") { $id5 = "default"; $path5 = "images/$id5.jpg"; } else { $id5 = rand(1,100000); $path5 = "images/$id5.jpg"; file_put_contents($path5,base64_decode($image5)); } } function checkfourth() { global $image4,$path4; if($image4=="No Image") { $id4 = "default"; $path4 = "images/$id4.jpg"; checkfive(); } else { $id4 = rand(1,100000); $path4 = "images/$id4.jpg"; file_put_contents($path4,base64_decode($image4)); checkfive(); } } function checkthird() { global $image3,$path3; if($image3=="No Image") { $id3 = "default"; $path3 = "images/$id3.jpg"; checkfourth(); } else { $id3 = rand(1,100000); $path3 = "images/$id3.jpg"; file_put_contents($path3,base64_decode($image3)); checkfourth(); } } function checksecond() { global $image2,$path2; if($image2=="No Image") { $id2 = "default"; $path2 = "images/$id2.jpg"; checkthird(); } else { $id2 = rand(1,100000); $path2 = "images/$id2.jpg"; file_put_contents($path2,base64_decode($image2)); checkthird(); } } if($image1=="No Image") { global $path1; $id1 = "default"; $path1 = "images/$id1.jpg"; checksecond(); } else { global $path1; $id1 = rand(1,100000); $path1 = "images/$id1.jpg"; file_put_contents($path1,base64_decode($image1)); checksecond(); } $pre_sql = "SELECT * FROM customer where email='$customer_email'"; $pre_result=mysqli_query($con,$pre_sql); while($row = mysqli_fetch_assoc($pre_result)){ $customer_id = $row['customer_id']; $name = $row['name']; } /*My Code*/ if($issue_title=="Skin") { global $path6; $question1 = $_POST['question1']; $question2 = $_POST['question2']; $question3 = $_POST['question3']; $prescription_image = $_POST['prescription_image']; if($prescription_image=="No Image") { $id6 = "default"; $path6 = "images/$id6.jpg"; } else { $id6 = rand(1,100000); $path6 = "images/$id6.jpg"; file_put_contents($path6,base64_decode($prescription_image)); } $sql = "INSERT INTO cases (customer_id,name,age,city,gender,issue_title,relation,image1,image2,image3,image4,image5,question1,question2,question3,prescription_image,issue_desc,case_id,date) VALUES ('$customer_id','$name','$age','$city','$gender','$issue_title','$relation','$path1','$path2','$path3','$path4','$path5','$question1','$question2','$question3','$path6','$issue_desc','$case_id','$today_date')"; } else{ /*Code's End*/ $sql = "INSERT INTO cases (customer_id,name,age,city,gender,issue_title,relation,image1,image2,image3,image4,image5,issue_desc,case_id,date) VALUES ('$customer_id','$name','$age','$city','$gender','$issue_title','$relation','$path1','$path2','$path3','$path4','$path5','$issue_desc','$case_id','$today_date')"; } $result=$con-&gt;query($sql); //Executing query to database if($result){ echo 'Order Added Successfully@' . $case_id; }else{ echo 'Could Not Add Order@00'; } //Closing the database mysqli_close($con); } ?&gt; </code></pre> <p>Swift 3 -&gt; Alamofire code:</p> <pre><code>func globalFuncUploadFile(withParams: [String:String], forURL: String, imageData: [String:Data], completionHandler: @escaping (JSON?, NSError?) -&gt; ()) { // To create a Semaphore to Sync this asyc method print(forURL) let semaphore = DispatchSemaphore(value: 0) Alamofire.upload(multipartFormData: { (MultipartFormData) in print(" File is appending with URL") for (key,data) in imageData{ print("\(key) is appending") MultipartFormData.append(data.base64EncodedData(), withName: key, fileName: key, mimeType: "\(key)/JPEG)") } for (key,value) in withParams{ print("\(key) is appending") MultipartFormData.append(value.data(using: .utf8)!, withName: key) } print("of size \(MultipartFormData.contentLength)") }, to: forURL, encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.uploadProgress(closure: { (Progress) in print("Upload Progress: \(Progress.fractionCompleted)\t\(Progress.completedUnitCount)/\(Progress.totalUnitCount)") }) upload.responseString { (value) in //Show Alert in UI switch value.result { case .success(let valueJson): print("Data uploaded \(valueJson)") completionHandler(JSON(valueJson), nil) break case .failure(let internalError): print("Data not uploaded -&gt; \(internalError)") completionHandler(nil, internalError as NSError?) break } } break case .failure(let encodingError): //Show Alert in UI print("Data not uploaded -&gt; \(encodingError)") completionHandler(nil, encodingError as NSError?) break } //Awaking Semaphore that session is complete semaphore.signal() } ) // Waiting for the semaphore signal _ = semaphore.wait(timeout: .distantFuture) } </code></pre> <p>If by any chance taking almost a minute, Images would uploaded to server by getting successful message from php code, then the images will not saved to database and generates this error: </p> <pre><code>PHP Notice: Undefined index: image1 in address.php on line 14 PHP Notice: Undefined index: image2 in address.php on line 15 PHP Notice: Undefined index: image3 in address.php on line 16 PHP Notice: Undefined index: image4 in address.php on line 17 PHP Notice: Undefined index: image5 in address.php on line 18 PHP Notice: Undefined index: prescription_image in address.php on line 143 </code></pre> <p>But most of the times, say 99 times out of 100; The time out error is generates in swift by alamofire (Swift Error Log with uploading process): </p> <pre><code>of size 2658665 Upload Progress: 0.0123166068590059 32768/2660473 Upload Progress: 0.0246332137180118 65536/2660473 Upload Progress: 0.0369498205770177 98304/2660473 Upload Progress: 0.0492664274360236 131072/2660473 Upload Progress: 0.0615830342950295 163840/2660473 Upload Progress: 0.0738996411540354 196608/2660473 Upload Progress: 0.0862162480130413 229376/2660473 Upload Progress: 0.0985328548720472 262144/2660473 Upload Progress: 0.110849461731053 294912/2660473 Upload Progress: 0.123166068590059 327680/2660473 Upload Progress: 0.135482675449065 360448/2660473 Upload Progress: 0.147799282308071 393216/2660473 Upload Progress: 0.160115889167077 425984/2660473 Upload Progress: 0.172432496026083 458752/2660473 Upload Progress: 0.184749102885088 491520/2660473 Upload Progress: 0.197065709744094 524288/2660473 Upload Progress: 0.2093823166031 557056/2660473 Upload Progress: 0.221698923462106 589824/2660473 Upload Progress: 0.234015530321112 622592/2660473 Upload Progress: 0.246332137180118 655360/2660473 Upload Progress: 0.258648744039124 688128/2660473 Upload Progress: 0.27096535089813 720896/2660473 Upload Progress: 0.283281957757136 753664/2660473 Upload Progress: 0.295598564616142 786432/2660473 Upload Progress: 0.307915171475147 819200/2660473 Upload Progress: 0.320231778334153 851968/2660473 Upload Progress: 0.332548385193159 884736/2660473 Upload Progress: 0.344864992052165 917504/2660473 Upload Progress: 0.357181598911171 950272/2660473 Upload Progress: 0.369498205770177 983040/2660473 Upload Progress: 0.381814812629183 1015808/2660473 Data not uploaded -&gt; Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x12ed8a7d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://***.php, NSErrorFailingURLKey=http://***.php, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.} Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x12ed8a7d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://***.php, NSErrorFailingURLKey=http://***.php, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.} </code></pre> <p>Hmm some extra information: The whole thing is working for both WIFI and for Network when I was testing in mobile with SIM but when SIM got ejected by the owner; I left up with only WIFI, and face this thing.</p> <p>There is gap of a day between SIM and no SIM scenario as I'm on leave. In between there have some changes on php side which is hard to mention by me. Thanks in advance for your cooperation.</p> </div>

NSSetUncaughtExceptionHandler swift怎么用?

NSSetUncaughtExceptionHandler swift当中怎么用


有段oc代码如下: typedef void(^RootViewMoveBlock)(UIView *rootView,CGRect orginFrame,CGFloat xoffset); @property (copy,nonatomic) RootViewMoveBlock rootViewMoveBlock;//可在此block中重做动画效果 - (void)setRootViewMoveBlock:(RootViewMoveBlock)rootViewMoveBlock; 调用代码如下: [sideViewController setRootViewMoveBlock:^(UIView *rootView, CGRect orginFrame, CGFloat xoffset) { //使用简单的平移动画 rootView.frame=CGRectMake(xoffset, orginFrame.origin.y, orginFrame.size.width, orginFrame.size.height); }]; 请问用swift怎么调用?


这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程






系统介绍 图书馆管理系统主要的目的是实现图书馆的信息化管理。图书馆的主要业务就是新书的借阅和归还,因此系统最核心的功能便是实现图书的借阅和归还。此外,还需要提供图书的信息查询、读者图书借阅情况的查询等




发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...


这门课程基于主流的java8平台,由浅入深的详细讲解了java SE的开发技术,可以使java方向的入门学员,快速扎实的掌握java开发技术!


文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...




本课程适合CCNA或HCNA网络小白同志,高手请绕道,可以直接学习进价课程。通过本预科课程的学习,为学习网络工程师、思科CCNA、华为HCNA这些认证打下坚实的基础! 重要!思科认证2020年2月24日起,已启用新版认证和考试,包括题库都会更新,由于疫情原因,请关注官网和本地考点信息。题库网络上很容易下载到。


深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷


Ubuntu18.04.1安装一、准备工作1.下载Ubuntu18.04.1 LTS2.制作U盘启动盘3.准备 Ubuntu18.04.1 的硬盘空间二、安装Ubuntu18.04.1三、安装后的一些工作1.安装输入法2.更换软件源四、双系统如何卸载Ubuntu18.04.1新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列...


原理:    快速排序,说白了就是给基准数据找其正确索引位置的过程.    如下图所示,假设最开始的基准数据为数组第一个元素23,则首先用一个临时变量去存储基准数据,即tmp=23;然后分别从数组的两端扫描数组,设两个指示标志:low指向起始位置,high指向末尾.    首先从后半部分开始,如果扫描到的值大于基准数据就让high减1,如果发现有元素比该基准数据的值小(如上图中18&amp;lt...


【超实用课程内容】 本课程演示的是一套基于Java的SSM框架实现的图书管理系统,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的java人群。详细介绍了图书管理系统的实现,包括:环境搭建、系统业务、技术实现、项目运行、功能演示、系统扩展等,以通俗易懂的方式,手把手的带你从零开始运行本套图书管理系统,该项目附带全部源码可作为毕设使用。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/27513 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/27513,点击右下方课程资料、代码、课件等打包下载




&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。


想学好JAVA必须要报两万的培训班吗? Java大神勿入 如果你: 零基础想学JAVA却不知道从何入手 看了一堆书和视频却还是连JAVA的环境都搭建不起来 囊中羞涩面对两万起的JAVA培训班不忍直视 在职没有每天大块的时间专门学习JAVA 那么恭喜你找到组织了,在这里有: 1. 一群志同道合立志学好JAVA的同学一起学习讨论JAVA 2. 灵活机动的学习时间完成特定学习任务+每日编程实战练习 3. 热心助人的助教和讲师及时帮你解决问题,不按时完成作业小心助教老师的家访哦 上一张图看看前辈的感悟: &nbsp; &nbsp; 大家一定迫不及待想知道什么是极简JAVA学习营了吧,下面就来给大家说道说道: 什么是极简JAVA学习营? 1. 针对Java小白或者初级Java学习者; 2. 利用9天时间,每天1个小时时间; 3.通过 每日作业 / 组队PK / 助教答疑 / 实战编程 / 项目答辩 / 社群讨论 / 趣味知识抢答等方式让学员爱上学习编程 , 最终实现能独立开发一个基于控制台的‘库存管理系统’ 的学习模式 极简JAVA学习营是怎么学习的? &nbsp; 如何报名? 只要购买了极简JAVA一:JAVA入门就算报名成功! &nbsp;本期为第四期极简JAVA学习营,我们来看看往期学员的学习状态: 作业看这里~ &nbsp; 助教的作业报告是不是很专业 不交作业打屁屁 助教答疑是不是很用心 &nbsp; 有奖抢答大家玩的很嗨啊 &nbsp; &nbsp; 项目答辩终于开始啦 &nbsp; 优秀者的获奖感言 &nbsp; 这是答辩项目的效果 &nbsp; &nbsp; 这么细致的服务,这么好的氛围,这样的学习效果,需要多少钱呢? 不要1999,不要199,不要99,只要9.9 是的你没听错,只要9.9以上所有就都属于你了 如果你: 1、&nbsp;想学JAVA没有基础 2、&nbsp;想学JAVA没有整块的时间 3、&nbsp;想学JAVA没有足够的预算 还等什么?赶紧报名吧,抓紧抢位,本期只招300人,错过只有等时间待定的下一期了 &nbsp; 报名请加小助手微信:eduxy-1 &nbsp; &nbsp;


C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。




本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。


YOLOv3是一种基于深度学习的端到端实时目标检测方法,以速度快见长。本课程将手把手地教大家使用labelImg标注和使用YOLOv3训练自己的数据集。课程分为三个小项目:足球目标检测(单目标检测)、梅西目标检测(单目标检测)、足球和梅西同时目标检测(两目标检测)。 本课程的YOLOv3使用Darknet,在Ubuntu系统上做项目演示。包括:安装Darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 Darknet是使用C语言实现的轻型开源深度学习框架,依赖少,可移植性好,值得深入探究。 除本课程《YOLOv3目标检测实战:训练自己的数据集》外,本人推出了有关YOLOv3目标检测的系列课程,请持续关注该系列的其它课程视频,包括: 《YOLOv3目标检测实战:交通标志识别》 《YOLOv3目标检测:原理与源码解析》 《YOLOv3目标检测:网络模型改进方法》 敬请关注并选择学习!




《YOLOv3目标检测实战系列课程》旨在帮助大家掌握YOLOv3目标检测的训练、原理、源码与网络模型改进方法。 本课程的YOLOv3使用原作darknet(c语言编写),在Ubuntu系统上做项目演示。 本系列课程包括三门课: (1)《YOLOv3目标检测实战:训练自己的数据集》 包括:安装darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 (2)《YOLOv3目标检测:原理与源码解析》讲解YOLOv1、YOLOv2、YOLOv3的原理、程序流程并解析各层的源码。 (3)《YOLOv3目标检测:网络模型改进方法》讲解YOLOv3的改进方法,包括改进1:不显示指定类别目标的方法 (增加功能) ;改进2:合并BN层到卷积层 (加快推理速度) ; 改进3:使用GIoU指标和损失函数 (提高检测精度) ;改进4:tiny YOLOv3 (简化网络模型)并介绍 AlexeyAB/darknet项目。


一、下载MySQL 首先,去数据库的官网http://www.mysql.com下载MySQL。 点击进入后的首页如下:  然后点击downloads,community,选择MySQL Community Server。如下图:  滑到下面,找到Recommended Download,然后点击go to download page。如下图:  点击download进入下载页面选择No...


图像处理和计算机视觉的课程大家已经看过很多,但总有“听不透”,“用不了”的感觉。课程致力于创建人人都能听的懂的计算机视觉,通过生动、细腻的讲解配合实战演练,让学生真正学懂、用会。 【超实用课程内容】 课程内容分为三篇,包括视觉系统构成,图像处理基础,特征提取与描述,运动跟踪,位姿估计,三维重构等内容。课程理论与实战结合,注重教学内容的可视化和工程实践,为人工智能视觉研发及算法工程师等相关高薪职位就业打下坚实基础。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/26281 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,但是大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/26281,点击右下方课程资料、代码、课件等打包下载




安装第三方请求库 requests 被网站禁止了访问 原因是我们是Python过来的 重新给一段 可能还是存在用不了,使用网页的 编写代码 上面注意看匹配内容 User-Agent:请求对象 AppleWebKit:请求内核 Chrome浏览器 //请求网页 import requests import re //正则表达式 就是去不规则的网页里面提取有规律的信息 headers = { 'User-Agent':'存放浏览器里面的' } response = requests.get


分享思维,改变世界. web网页制作,期末大作业. 所用技术:html css javascript 分享所学所得

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

相关热词 c#跨线程停止timer c#批量写入sql数据库 c# 自动安装浏览器 c#语言基础考试题 c# 偏移量打印是什么 c# 绘制曲线图 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行