Skip to main content

PHP errors when using basic.php example

Comments

8 comments

  • Alexandros Binopoulos

    *Note: cloudinary_php require PHP 5.3*

     

     

    0
  • Itay Taragano

    Hi Alexandros ,

    If you're using PHP 5.2, we have our PHP 5.2 branch:

    https://github.com/cloudinary/cloudinary_php/tree/php5.2

    Please let me know if this works for you.

    0
  • Hans Halim

    Hi,

    I use PHP 5.2 and i have download from you link above, the Cloudinary API for PHP 5.2.

    Yet i still confused how to use it. This is my code, could you please take a look and edit it, as it still error.

     

    require (DIR_FS_INCLUDE . "/cloudbinary/src/Cloudinary.php");

            require (DIR_FS_INCLUDE . "/cloudbinary/src/Uploader.php");

            require (DIR_FS_INCLUDE . "/cloudbinary/src/Api.php");

            

            Cloudinary::config(array(

      "cloud_name" => "sample",

      "api_key" => "874837483274837",

      "api_secret" => "a676b67565c6767a6767d6767f676fe1"

    ));

            $ext = $fullname[count($fullname)-1];

            $newname = $_POST['Name'].date('YmdHis').'.'.$ext;

            $newname = str_replace(' ', '_', $newname);

            move_uploaded_file($_FILES["file"]["tmp_name"],DIR_FS_TEMP.'/upload/employment/'.$newname);

            $file = DIR_FS_TEMP.'/upload/employment/'.$newname;

            Cloudinary\Uploader::upload($file);

     

    The error is

    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in C:\www\scorplocal\include\process_post_values.php on line 634

    Parse error: parse error in C:\www\scorplocal\include\process_post_values.php on line 634

     

     

    Thanks

    0
  • Itay Taragano

    Notice that the usage might be slightly different for the 5.2 branch. Specifically, you'll need to use  CloudinaryUploader  instead of  Cloudinary\Uploader .

    See:

    https://github.com/cloudinary/cloudinary_php/blob/php5.2/tests/UploaderTest.php#L14

    Also, please note that your account's api_secret should be not be revealed. Please go to your  Security settings page in order to generate a new pair of api key and secret.

    0
  • Hans Halim

    Hi Itay,

     

    Thanks for your reply. in the last few weeks, i did not have much time to touch this project. and now, when i back i tried to download your example, but i dont know how to use it.

    i try to create a simple php code, to call the test_upload fuction. yet, i think is not working. below is the code

    error_reporting(E_ALL | E_STRICT);

    require_once('UploaderTest.php');

    $test = new UploaderTest();

    $test->setUp();

    $test->test_upload();

    every time i run that code, there are no respond, no error message as well.

     

    So, could you please give me a full example code(not just the class). that i can use to upload an image.

     

    Thanks

     

    Hans

    0
  • Itay Taragano

    Please note that UploaderTest.php is a unit test meant to be run with PHPUnit. It was shared just for code syntax clarification purposes.

    I believe you may try to use the exact same code you shared initially, but change Cloudinary\Uploader::upload($file); to be CloudinaryUploader::upload($file);

    0
  • Hans Halim

    Hi,

    Thanks for your reply. i just try to create this code, and when i tried, it sill not working.

    error_reporting(E_ALL | E_STRICT);

    $base = realpath(dirname(__FILE__).'/../');

    require_once($base . DIRECTORY_SEPARATOR . 'src/Cloudinary.php');

    require_once($base . DIRECTORY_SEPARATOR . 'src/Uploader.php');

    $result = CloudinaryUploader::upload("logo.png");

    dump($result);

     

    and, in which file i need to declare my API key and secret, in which part.

     

    Thanks

    0
  • Itay Taragano

    The account's credentials should be either included in your php file or include an external settings file, as demonstrated in our PHP sample project:

    https://github.com/cloudinary/cloudinary_php/blob/master/samples/PhotoAlbum/main.php#L10

    https://github.com/cloudinary/cloudinary_php/blob/master/samples/PhotoAlbum/settings.php.sample

    For more information:

    http://cloudinary.com/documentation/php_integration#configuration

    If you still require further assistance, please  open a support ticket so we can further get to the root of this issue.

    0

Post is closed for comments.