这里主要针对局域网内的电脑向手机端传输文件,常见的就是同一wifi下的设备间的传输。

第三方软件

这种方法下,文件一般会被存在某个服务器里。

  • QQ、微信这样的常用工具。但是微信会遇到平板和手机不能同时在线的问题,所以有时不是很方便。
  • 邮件附件。
  • 自建HTTP服务器

    Python

    关键模块 http.server
    网上的教程更多在使用形如这样的指令: python -m http.server 8000
    但是这样默认使用的是localhost ,这个地址实际上表示的使用这个指令的机器本身,如果我们想要在局域网内访问,需要指定一个局域网内可以访问的IP,这里我们可以使用192.168.x.y 系列的IP。一个简单的讨论如下:

    In a little more laymen’s terms: 127.0.0.1 is your computer. If you ping it - you’re pinging yourself, if you try to explore files on it, you’re exploring files on your computer. This address is created to test your computer’s networking protocols without actually using the network your computer is connected to. It is called a loopback address - you can think of it as a cable that leaves your computer and loops around to plug back into your computer, rather than being plugged into the network. Your computer cannot and will not communicate with any devices other than itself using this address. Your 192.168.x.x address is the network created by your router where all of your networked devices communicate. Here you can also see and communicate with your own computer by referencing the address it has been assigned, but you can also communicate with any other device on that network. https://www.quora.com/What-is-the-difference-between-127-0-0-1-and-192-168-x-y-in-terms-of-computer-networking Here what you see is the adapter named “Local Area Connection” with IP address 192.168.1.36, while 127.0.0.1 is the address of the loopback adapter in each PC. There are many types of IP. Things like 10.x.x.x or 192.168.x.x are private addresses which are used to identify your computer inside the local network. Outsiders cannot see what’s inside the local network because they have been hidden after NAT. Each local network will connect with WAN via a router and have a public IP address with the interface facing WAN of the router. If your computer is connected directly to public internet (which is extremely unlikely in an IPv4 network due to the limit in the address range and the high price of static IPs) then you’ll have WAN (public) IP address too.

但是不是随便的 x & y 都可以,最简单的方式可以在你的cmd里(假定你是用的是windows)输入 ipconfig 来查看关于IP的一些信息。里面会显示一条信息:“无线局域网适配器 WLAN”里的“IPv4 地址 . . . . . . . . . . . . : 192.168.xx.yy”。我们可以使用这个地址来作为我们要在局域网内搭建服务器的IP。也就是我们可以使用如下指令:

  1. python -m http.server 8000 --bind 192.168.xx.yy

这个时候我们便可以在同一局域网的设备上浏览和下载执行这个指令的文件夹里的内容。
更多内容可以参考文档:

Chrome

Chrome插件里有一个很有用的插件:Web Server for Chrome
https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?utm_source=chrome-app-launcher-info-dialog
这是它的信息:

A Web Server for Chrome, serves web pages from a local folder over the network, using HTTP. Runs offline. Web Server for Chrome is an open source (MIT) HTTP server for Chrome. It runs anywhere that you have Chrome installed, so you can take it anywhere. It even works on ARM chromebooks.

It now has the option to listen on the local network, so other computers can access your files. Additionally, it can try and get an internet address.

Many people use this to do basic web development on a chromebook. It is also handy for sharing files over a local network between computers, or even on the internet.

他提供的功能和丰富:
image.png
安装成功后在chrome的应用里可以看到这个插件,点击后会弹出上图的选项卡,通过 choose folder 来设置共享内容的文件夹。
因为我们仅仅是为了在局域网内传输文件,所以我们选择 accessible on local network ,但是我们不选择 also on internet ,竖标移动对应条目上可以看到选项的一些介绍。后面这个应该是用来共享到公网的。其他的选项可以自行了解选用。
注意,第一次设置使用局域网可能前面的 web servel urls 里没有显示适用于局域网的IP地址,这个时候只需要关闭重新打开这个image.png选项即可看到 198 系列的URLs地址。
之后我们只需要在同一局域网下的设备的浏览器里,输入这里显示的地址,即可看到对应的文件夹下的内容。