在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
php使用curl上传文件,代码如下: 发送的代码(完全是官方的示例) <?php /* http://localhost/upload.php: $ch = curl_init(); $data = array('name' => 'Foo', 'file' => '@/home/vagrant/test.png'); curl_setopt($ch, CURLOPT_URL, 'http://localhost/test/curl/load_file.php'); curl_exec($ch); 接收代码(也是官方的) <?php php -f demo.php 解决方法1: /* http://localhost/upload.php: $ch = curl_init(); $data = array('name' => 'Foo', 'file' => '@/home/vagrant/test.png'); curl_setopt($ch, CURLOPT_URL, 'http://localhost/test/curl/load_file.php'); curl_exec($ch); 解决方法2: /* http://localhost/upload.php: $ch = curl_init(); $data = array('name' => 'Foo', 'file' => new \CURLFile(realpath('/home/vagrant/test.png'))); curl_setopt($ch, CURLOPT_URL, 'http://localhost/test/curl/load_file.php'); curl_exec($ch);
相关文章: php curl文件上传兼容php5.0~5.6各版本 http://www.cnblogs.com/zqifa/p/php-curl-2.html |
2022-07-18
2022-08-17
2022-11-06
2022-08-17
2022-08-15
请发表评论