gaojie1592 / download_network_data_to_local
下载网络数据识别文件后缀后保存到本地并返回本地地址.Download the network data identification file suffix, save it to the local and return to the local address.
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.4
README
功能说明:
将网络数据下载并自动识别文件后缀,保存到本地并返回本地地址.
Download network data and automatically recognize the file suffix, save it locally and return to the local address.
安装方法:
composer require gaojie1592/download_network_data_to_local
使用方法:
- 例子一:
require_once __DIR__ . '/vendor/autoload.php'; use gaojie1592\Download_Network_Data_To_Local; $img = new Download_Network_Data_To_Local( // 必要参数:需要下载的网络地址,必须是完整的 // Necessary parameters: the network address to be downloaded must be complete 'http://www.github.com/gif_download', // 必要参数:保存到本地的地址,不包含文件名称,以'/'或'\'结尾 // Necessary parameters: save to the local address, do not include the file name, end with'/' or'\' '/home/www.github.com/img/', // 可选参数:可以指定保存的文件名称,如果不指定则用随机字符 // Optional parameter: you can specify the saved file name, if not specified, use random characters 'filename' ); $local = $img->start(); var_dump($local); // 返回结果 string() "/home/www.github.com/img/filename.gif"
- 例子二:
require_once __DIR__ . '/vendor/autoload.php'; use gaojie1592\Download_Network_Data_To_Local; $img = new Download_Network_Data_To_Local(); // 必要参数:需要下载的网络地址,必须是完整的 // Necessary parameters: the network address to be downloaded must be complete $local = $img->set_http_url('http://www.github.com/jpg_download') // 必要参数:保存到本地的地址,不包含文件名称,以'/'或'\'结尾 // Necessary parameters: save to the local address, do not include the file name, end with'/' or'\' ->set_local_path('/home/www.github.com/img/') // 可选参数:可以指定保存的文件名称,如果不指定则用随机字符 // Optional parameter: you can specify the saved file name, if not specified, use random characters ->set_filename('filename') ->start(); var_dump($local); // 返回结果 string() "/home/www.github.com/img/filename.jpg"
- 例子三:
require_once __DIR__ . '/vendor/autoload.php'; use gaojie1592\Download_Network_Data_To_Local; $img = new Download_Network_Data_To_Local(); // 必要参数:需要下载的网络地址,必须是完整的 // Necessary parameters: the network address to be downloaded must be complete $local = $img->set_http_url('http://www.github.com/jpg_download') // 必要参数:保存到本地的地址,不包含文件名称,以'/'或'\'结尾 // Necessary parameters: save to the local address, do not include the file name, end with'/' or'\' ->set_local_path('/home/www.github.com/img/') // 可选参数:可以指定保存的文件名称,如果不指定则用随机字符 // Optional parameter: you can specify the saved file name, if not specified, use random characters ->set_filename('filename') // 可选参数:下载持续的最大时间,需要下载的文件体积越大,则设置越大 // Optional parameter: the maximum time for downloading, the larger the file size to be downloaded, the larger the setting ->set_http_timeout(50) // 可选参数:连接服务器的最大等待时间,如果网络不好,则设置大点 // Optional parameter: the maximum waiting time to connect to the server, if the network is not good, set a larger one ->set_http_sertimeout(50) // 可选参数:使用代理下载 // Optional parameter: download using proxy ->set_http_proxy('192.168.0.1:1080') // 可选参数:使用代理的账号与密码 // Optional parameters: use proxy account and password ->set_http_proxyusrpwd('usrname:password') ->start(); var_dump($local); // 返回结果 string() "/home/www.github.com/img/filename.jpg"
支持文件后缀:
- js
- psd
- htm_or_html
- xml
- bmp
- gif
- exe
- midi
- zip
- rar
- bt
- png
- bat
- xls_or_doc_or_ppt
- txt_or_aspx_or_asp_or_sql
- jpg
- rdp
许可证:
当前软件使用的许可证是 MIT,请查看完整的许可证.
This bundle is under the MIT license. See the complete license in the bundle.