How to upload images with Cloudinary and PHP

Asked

Viewed 175 times

1

My client is clueless. He sends photos of 4MB to the system, and complains about speed.

I’m thinking about using the Cloudinary to solve this problem. There are libraries for PHP in the documentation. But I am without a good reasoning to use the service.

Someone has already used and can give me some guidance on this implementation?

In my present, I rule this way:

    <?php
header('Access-Control-Allow-Origin: *');

// ESTE ARQUIVO DEVE ESTAR EM admin/vovos/_lib/file/img E SETADO EM CADASTRPDELICIAS_CONTROLLER
$target_path = "app_img/";

$target_path = $target_path . basename( $_FILES['file']['name']);

if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
    echo "Upload and move success";
} else{
echo $target_path;
    echo "There was an error uploading the file, please try again!";
}
?>

I changed my PHP to:

<?php
header('Access-Control-Allow-Origin: *');

require 'Cloudinary.php';
require 'Uploader.php';
require 'Api.php';

\Cloudinary::config(array( 
  "cloud_name" => "meu_name", 
  "api_key" => "meu_key", 
  "api_secret" => "meu_secret" 
));


$target_path = \Cloudinary\Uploader::upload("http://res.cloudinary.com/ramosinfo/app_img/");



\Cloudinary\Uploader::upload($_FILES["file"]["tmp_name"]);

if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
    echo "Upload and move success";
} else{
echo $target_path;
    echo "There was an error uploading the file, please try again!";
}
?>

According to documentation, but I still can’t send...

No answers

Browser other questions tagged

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