我正在尝试使用php curl_setopt
将图像上传到服务器,但是只要包含403 Forbidden
,我总是会得到base64_encode($image_data)
,但是如果没有,它将成功发布。我也尝试过更改php.in
,但仍然没有。之前一切工作正常,直到我在centos服务器中重新安装新的操作系统之前,我还不真正知道原因。
MY PHP.INI
memory_limit=512M
upload_max_filesize=12M
post_max_size=128M
max_execution_time=60
max_input_vars=4000
#session.save_path=\\
session.save_path="/sessions_tmp"
magic_quotes_gpc=Off
session.gc_maxlifetime=365 * 24 * 60 * 60
session.cookie_lifetime=365 * 24 * 60 * 60
session.gc_divisor=1
session.gc_probability=1
我的PHP上传
if(($fileHandle = fopen($_FILES['image']['tmp_name'], "r"))){
$data = fread($fileHandle, filesize($_FILES['image']['tmp_name']));
$postVar = array(
/*This will work but using $data won't work
'image' => base64_encode("UploadTest"),*/
'image' => base64_encode($data),
'product_id' => '1020039393',
'image_name' => 'tempCarImage.png',
'file_name' => "CarImage",
'upload' => 'GALLERY',
'tag' => 1,
'extension' => 'png',
'chef_key' => 'M573Hakd'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://example.com/assets/upload.php");
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . upload_cdn_server_key));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, '');
curl_setopt($curl, CURLOPT_POSTFIELDS, $postVar);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$out = curl_exec($curl);
$err = curl_error($curl);
curl_close ($curl);
fclose($fileHandle);
$pms = json_decode($out,true);
}
请任何人可以帮助我,我真的不知道是什么导致了这个问题。