目前我使用的是Php 5.2版本。 下面的代码在旧版本
上工作正常$ch = curl_init();
if(isset($file['image']) || isset($file['image1']))
{
if(isset($file['image']) && $file['image']['error'] == 0)
{
$filename = $file['image']['name'];
$filedata = $file['image']['tmp_name'];
$filesize = $file['image']['size'];
}
elseif(isset($file['image1']) && $file['image1']['error'] == 0)
{
$filename = $file['image1']['name'];
$filedata = $file['image1']['tmp_name'];
$filesize = $file['image1']['size'];
}
else
{
if(isset($post['nonJSAddProduct']) && $post['nonJSAddProduct'] == 'Y'){
return "not uploaded";
}else{
echo "not uploaded";die;
}
}
}
if(isset($post['filenme_final']) && $post['filenme_final'] !='')
$post['imagename']=$post['filenme_final'];
else
$post['imagename']=$filename;
$post['image']="@$filedata";
$headers = array("Content-Type:multipart/form-data");
if ($_SERVER["HTTP_X_FORWARDED_SERVER"] == 'dev-m.indiamart.com' )
{
curl_setopt($ch, CURLOPT_URL, 'http://dev-mapi.indiamart.com/wservce/products/uploadimage/');
}
if ($_SERVER["HTTP_X_FORWARDED_SERVER"] == 'dev-m.indiamart.com' || $_SERVER["HTTP_X_FORWARDED_SERVER"] == 'stg-m.indiamart.com')
curl_setopt($ch, CURLOPT_USERPWD, "admin:admin");
$options = array(
//CURLOPT_HEADER => true,//if we remove it then it not prints extra data like 200 ok
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $post,
CURLOPT_INFILESIZE => $filesize,
CURLOPT_RETURNTRANSFER => true
); // cURL options
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
curl_close($ch);
$dataProvider = (array) json_decode($response, true);
return $dataProvider;
现在我们正在迁移到php 5.6.16但是当我在新版本上运行相同的代码时,即5.6.16,当我打印$ _FILES数组时,在api结束时,我变得空白。
请帮忙,此代码中的错误在哪里