html - Uploading Image to Cloudinary API with PHP -


i new @ this... trying upload image cloudinary api account using php. i've been receiving following errors; though have given api_key , api_secret.

fatal error: uncaught exception 'invalidargumentexception' message 'must supply api_key' in c:\xampp\htdocs\-\php\cloudinary.php:786  stack trace: #0 c:\xampp\htdocs\-\php\uploader.php(247):  cloudinary::sign_request(array, array) #1 c:\xampp\htdocs\-\php\uploader.php(62):  cloudinary\uploader::call_api('upload', array, array, 'c:\\xampp\\tmp\\ph...') #2 c:\xampp\htdocs\-\php\addproverbs.php(12):  cloudinary\uploader::upload('c:\\xampp\\tmp\\ph...') #3 {main} thrown in c:\xampp\htdocs\-\php\cloudinary.php on line 786 

in php have provided details shown below...

<?php     $prov = json_decode(file_get_contents("php://input"));     require_once("connection.php");     require 'cloudinary.php';     require 'uploader.php';     require 'api.php';     $connection = connecttomysql();      $proverbdescription = $prov->proverbdescription;     $proverbnumber = $prov->proverbnumber;       $imgpath = $prov->imgpath;     $cloudupload = \cloudinary\uploader::upload($_files["imgpath"]['tmp_name']);      \cloudinary::config(array(     "cloud_name" => "xxxxxx",     "api_key" => "xxxxxxx", //hidden obvious reasons     "api_secret" => "xxxxxxxx"     ));     if (isset($_post["submit"])) {         print_r($_files["imgpath"]);         $cloudupload = \cloudinary\uploader::upload($_files["imgpath"]['tmp_name']);         print_r($cloudupload);     }     $query = "insert tbl_proverb (proverbdescription, proverbnumber, imgpath) values ('$proverbdescription', '$proverbnumber', '$cloudupload')";      $result = mysqli_query($connection, $query)          or die("error in query: ". mysqli_error($connection));     if(mysqli_affected_rows($connection) > 0){             $success = true;     }else{             $success = false;     }            ?> 

this html form contains image upload , 2 textboxes.

<form id="demo" class="collapse" action="php/addproverbs.php" ng-submit="addproverb(prov)" enctype="multipart/form-data" method="post">     <label>image:</label>          <input type="file" ng-model="prov.imgpath" name="imgpath" id="imgpath" accept="image/*">     <label>proverb description:</label>         <input type="text" ng-model="prov.proverbdescription" ><br><br>     <label>proverb number:</label>                                   <input type="text" ng-model="prov.proverbnumber"><br><br>     <input type="submit" name="submit"><br>     <a href="#/proverbs">see post</a> </form> 

sorry basic question quite new this.

thanks alot!


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -