Skip to main content

PHP server side Error

Comments

9 comments

  • Raz Ziv

    Hi,

    Can you please share your code so we can take a look and advise?
    If you prefer doing this on a private channel, you can share your code over a new support ticket created via support@cloudinary.com or at https://support.cloudinary.com/hc/en-us/requests/new.

    Best,
    Raz

    0
  • MEI
    Sure,
     
    here is the (Laravel) code 
     
    ```
    public function show(Post $post)
    {
        $result = Uploader::upload(public_path($post->img));
        dd($result);
    }
    ```
     
     
    and this is how I tried the 'Cloudder'
     
    which causes the "white list error":

    Cloudinary\Error
    Upload preset must be whitelisted for unsigned uploads
     
    BTW: I tried Cloudder and it's working but I like to avoid using third party packages!
    0
  • Erwin Lukas

    Hi,

    From the provided code you have, I don't see where you pass the upload preset in the options parameter.

    And also, the upload method should be:

    $result = \Cloudinary\Uploader::upload($file, $options = array());

    You can refer more to our documentation for more information

    Regards,
    Erwin Lukas

    0
  • MEI

    Hey,
    Based on the documentation, the upload preset is not required if it is not unsigned-upload, right?

    Anyway, I've tried all combinations crossed my mind and none of them work!

    this:
    $result = Uploader::upload(public_path($post->img), ['upload_preset' => 'ml_default']);

    this:
    $result = Uploader::unsigned_upload(public_path($post->img), 'an_unsigned_preset');

    even this:
    $result = Uploader::upload(public_path($post->img), 'ml_default');
     
    and I'm getting the same error!
    0
  • Raz Ziv

    Hey,

    Can you please share your cloud name so I can take a look at our logs?

    Thanks,
    Raz

    0
  • MEI

    Hey Raz,

    it's "middleeastimage"

    0
  • Raz Ziv

    Thanks for sharing your cloud name with me.

    Upon taking a look at our logs, I can see that the requests we receive come without an API Key and are also missing the file.
    When a request is made without the API Key and Secret, it is treated as an unsigned upload and thus the need for the upload preset to be included for the request to get through.
    The ml_default preset is a signed preset and not an unsigned one. That is probably why you still get this error even when providing this preset as part of the request.

    How do you currently configure your account's credentials within your code?

    Can you please make sure that both echo \Cloudinary::config_get("api_key"); and echo public_path($post->img); return the expected value right before you call $result = Uploader::upload(public_path($post->img));?

    0
  • MEI

    It's not the case, all three required strings (api_key, api_secret and cloud_name) are present

    ```
    \Cloudinary::config_get("api_key");
    \Cloudinary::config_get("api_secret");
    \Cloudinary::config_get("cloud_name");
    ```

    As well as the image path!
    Ive tried both absolute and relative paths:

    ```
    "/Users/my_user/projects/valet/mei/public/img/temp/001.jpg"
    "/img/temp/001.jpg"
    "img/temp/001.jpg"
    ```

    Also, I have tried both signed and unsigned uploads (of course I have an unsigned-upload preset)

    ```
    Uploader::unsigned_upload($img_path, 'pzaix8dd');
    $result = \Cloudinary\Uploader::upload($img_path);
    ```

    this is the API environment variable I've used (with the actual variables)
    CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@CLOUD_NAME

    0
  • Raz Ziv

    Hi,

    In order for us to further investigate this I may need you to open a support ticket where you can share more details about your project's code, structure, and configuration.
    Based on the information you provided so far, I couldn't reproduce the issue on our end, yet I can see your requests are received in our servers without some relevant parameters.

    Please mention the URL of this thread in your ticket for a better association with the case.

    0

Post is closed for comments.