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)
равно нулю.
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;
Других решений пока нет …