您好,欢迎访问一九零五行业门户网

关于CURL上传问题

php 'foo', 'file' => new \curlfile(realpath('1.jpg'))); //绝对路径 curl_setopt($ch, curlopt_url, 'http://localhost/post.php'); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); curl_exec($ch);?>

假设我要上传的文件来自网络
网络文件图片url如下:http://7sbpxj.com1.z0.glb.clouddn.com/firstpage
我file = “网络文件”
那么该怎么写
回复内容: php 'foo', 'file' => new \curlfile(realpath('1.jpg'))); //绝对路径 curl_setopt($ch, curlopt_url, 'http://localhost/post.php'); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); curl_exec($ch);?>

假设我要上传的文件来自网络
网络文件图片url如下:http://7sbpxj.com1.z0.glb.clouddn.com/firstpage
我file = “网络文件”
那么该怎么写
直接在post.php下载远程文件
$file=file_get_contents($_post['file']);
file_put_contents($file, $temp);
直接上代码吧;
curl上传图片完整版
如果post.php支持网络文件,应该把地址给它就行,或者就先下载到本地文件吧。
curlfile 印象中是不能写网络图片url的吧
所以你还是自己下载下来再post吧
phpcouldn't open file http://7sbpxj.com1.z0.glb.clouddn.com/firstpage
其它类似信息

推荐信息