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?– Don't Panic
Yes. Curl support: enabled
– WebCraft
Try to put it like this:
new \CurlFile(
, or take the other test according to this link– Don't Panic