Estou tentando converter um arquivo .png para .jpg usando a API do CloudConvert mas da o seguinte erro:
cURL error 7: Failed to connect to api.cloudconvert.com port 443: Timed out (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Não Converteu!!!
O codigo é o seguinte:
<!DOCTYPE html>
<html>
<head>
<title>PHP - Cloudconvert API Example</title>
</head>
<body>
<div class="container">
<form method="POST" action="indexPro.php" enctype="multipart/form-data">
<div class="form-group">
<label>Add Image:</label>
<input type="file" name="file" class="form-control">
</div>
<div class="form-group">
<button class="btn btn-success">Submit</button>
</div>
</form>
</div>
</body>
</html>
<?php
require 'phar://cloudconvert-php.phar/vendor/autoload.php';
set_time_limit(0);
use \CloudConvert\Api;
$api = new Api("API Key");
if(!empty($_FILES["file"])){
try {
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$uploadFilePath = 'conversoes\slide.'.$ext;
move_uploaded_file($_FILES['file']['tmp_name'], $uploadFilePath);
$api->convert([
"inputformat" => $ext,
"outputformat" => "jpg",
"input" => "upload",
"save" => true,
"file" => fopen($uploadFilePath, 'r'),
])
->wait()
->download('conversoes\\slide.jpg');
} catch (Exception $e) {
echo $e->getMessage()."<br>";
}
if(file_exists('conversoes/output.jpg')){
echo ("Converteu!!!");
} else {
echo "Não Converteu!!!";
}
exit;
}else{
print_r("Pls Select image");
exit;
}
?>