Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP和cURL上传图像_Php_Image_Post_Curl_Upload - Fatal编程技术网

使用PHP和cURL上传图像

使用PHP和cURL上传图像,php,image,post,curl,upload,Php,Image,Post,Curl,Upload,我在试图发布一些数据时遇到了问题,其中有一个文件(图像)是我想要上传的。使用PHP5.3.3和Curl7.20.0 这是php脚本(图像位于我检查路径是否有效的同一文件夹中) 我错过了什么?这对你们有用吗 curl请求似乎没有问题,请查看以下结果: headers = POST /test/test.php HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/2006

我在试图发布一些数据时遇到了问题,其中有一个文件(图像)是我想要上传的。使用PHP5.3.3和Curl7.20.0

这是php脚本(图像位于我检查路径是否有效的同一文件夹中)

我错过了什么?这对你们有用吗

curl请求似乎没有问题,请查看以下结果:

headers = POST /test/test.php HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Host: localhost Accept: */* Referer: Content-Length: 82 Content-Type: application/x-www-form-urlencoded HTTP/1.1 200 OK Date: Sun, 11 Sep 2011 19:46:18 GMT Server: Apache/2.2.16 (Win32) PHP/5.3.3 X-Powered-By: PHP/5.3.3 Content-Length: 138 Content-Type: text/html $_POST = Array( [pic1] => @C:\wamp\www\test\image.jpg [postedvar1] => test1 [postedvar2] => test2 ) $_FILES = Array() headers=POST/test/test.php HTTP/1.1 用户代理:Mozilla/5.0(Windows;U;Windows NT 5.1;en-US;rv:1.8.1.1)Gecko/20061204 Firefox/2.0.0.1 主机:本地主机 接受:*/* 推荐人: 内容长度:82 内容类型:application/x-www-form-urlencoded HTTP/1.1200ok 日期:2011年9月11日星期日19:46:18 GMT 服务器:Apache/2.2.16(Win32)PHP/5.3.3 X-Powered-By:PHP/5.3.3 内容长度:138 内容类型:text/html $\u POST=数组( [pic1]=>@C:\wamp\www\test\image.jpg [postedvar1]=>test1 [postedvar2]=>test2 ) $\u FILES=Array()
要使用指定要上载的文件的
@filepath
方法,必须将
CURLOPT_POSTFIELDS
选项的值保留为数组

curl\u post\u request()
函数的第一行将数组转换为URL编码的字符串


请参阅手册中的
CURLOPT_POSTFIELDS
说明-

您会遇到哪些错误?
curl\u error()
?$\u POST中的任何内容都可以,但是$\u文件是空的!arobase似乎对请求没有影响。没有任何文件,请求似乎很顺利!请不要用“问题已解决!”-StackOverflow旨在成为未来的资源,同时也能帮助您。 headers = POST /test/test.php HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Host: localhost Accept: */* Referer: Content-Length: 82 Content-Type: application/x-www-form-urlencoded HTTP/1.1 200 OK Date: Sun, 11 Sep 2011 19:46:18 GMT Server: Apache/2.2.16 (Win32) PHP/5.3.3 X-Powered-By: PHP/5.3.3 Content-Length: 138 Content-Type: text/html $_POST = Array( [pic1] => @C:\wamp\www\test\image.jpg [postedvar1] => test1 [postedvar2] => test2 ) $_FILES = Array()