PHP
$filename=time().'.png';
$addressImage="/mahyapardaz/chap/tmp/".$filename;
$domain = $_SERVER['HTTP_HOST'];
$prefix = 'http://';
$relative = '/mahyapardaz/viewer/add_pic.php';
$target_url =$prefix.$domain.$relative ;
$file_name_with_full_path = realpath($addressImage);
$fields = array(
'code' => $code,
'iddarkh 'insertdaste' => ($BPM_MahaleNameDarArchive["Daste"]),
'insertnoe' => ($BPM_MahaleNameDarArchive["Noe"]),
'codeMeli' => (''),
'shemareSafhe' => ('1'),
'newVersion' => (''),
'image' => '@'.$file_name_with_full_path,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
为字段名@
设置image
时curl不起作用且不会调用app_pic
但是当从image
删除'@'时这项工作正常吗?
为什么?
也许realpath
不正确!?
并且var_dump($result)
等于null。
答案 0 :(得分:0)
1.检查文件是否存在
if (file_exists($file_name_with_full_path)) {
echo "The file $file_name_with_full_path exists";
} else {
echo "The file $file_name_with_full_path does not exist";
}
2
$file_name_with_full_path = realpath('.').'\\tmp\\'.$filename;