Error with Curlfile

Asked

Viewed 91 times

0

Hello, everybody. I have the following code:

<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" value="POST">
</form>

<?php
if (isset($_FILES['image']['tmp_name'])){

	$ch = curl_init();
	$cfile = new CURLFile($_FILES['image']['tmp_name'], $_FILES['image']['type'], $_FILES['image']['name']);
	$data = array("myimage" => $cfile);

	curl_setopt($ch, CURLOPT_URL, "http://meuhost/upload.php");
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

	$response = curl_exec($ch);

	if($response == true) {echo "Arquivo enviado";}
	else {echo "Erro: " . curl_error($ch);}
	
}
?>

However, the following error is returning to me.

Fatal error: Class 'CURLFile' not found in /var/www/protocolo/teste/cria.php on line 10

What can it be? My CURL is enabled on the server!

  • You looked at it on phpinfo(); to check if it is enabled?

  • Yes. Curl support: enabled

  • Try to put it like this: new \CurlFile( , or take the other test according to this link

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.