Principle
Using the Cocoahttpserver framework, a local server is established on the iOS side, so long as the computer and mobile phone are connected to the same hotspot or network, the pages of the iOS server can be accessed via the Computer browser, and the file upload is implemented with post.
Realize
1. Download Cocoahttpserver
2. Import the CocoaHTTPServer-master
Core folder under the directory
3. Import the Samples/SimpleFileUploadServer
MyHTTPConnection
class files and folders under the directory web
When importing Web folders, be sure to use the real directory instead of the Xcode virtual directory
4. Configure the server startup in the appropriate place. Here take Appdelegate as an example
5. After running, the console will print out the port number and IP, in the computer-side browser input ip+ port number access, if successful, you will see the following interface:
Access succeeded. png
6. If the upload is successful, the uploaded file name will appear on the webpage, and you can verify the file upload success in the sandbox.
(There are many forms of uploaded files, pictures, text, video can be, remember that the computer and mobile phone connected to the same hotspot or network)
Give me a chestnut: https://pan.baidu.com/s/1jIf95u2
Using Cocoahttpserver to build a mobile phone local server