Я использую библиотеку FPDF для генерации файлов, и у меня проблема с методом fopen. Я загружаю изображения по URL, я генерирую изображения qrcodes и т. Д. Fopen не работает с новым сервером, но в phpinfo allow_url_fopen: On
я пытаюсь перестроить метод с использованием cURL, но это не просто
protected function _parsepng($file) {
// Extract info from a PNG file
$fopen = false;
if ($fopen){
$f = fopen($file, 'rb');
if (!$f)
$this->Error('Can\'t open image file: ' . $file);
$info = $this->_parsepngstream($f, $file);
fclose($f);
return $info;
} else {
$f = fopen('php://temp', 'w+');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_FILE, $f);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
//curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_POSTFIELDS,[]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
if (!$f)
$this->Error('Can\'t open image file: ' . $file);
$info = $this->_parsepngstream($f, $file);
curl_close($ch);
return $info;
}
}
у кого-нибудь есть решение?