Skip to content

Error: Call to undefined function cl_image_upload_tag() in element #7

Closed

Description

@robksawyer

I think I should have posted the following question to this repo first.
cloudinary/cloudinary_js#12

Any ideas of what may be the issue?

Activity

  1. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    I just tried running your code under cakephp 2.4.1 and php 5.4 and it works fine (with the exception that the App::import calls should not have .php in them). What versions of php and cakephp are you using?

  2. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    I'm using 5.4.19 and 2.4.1. Note: I'm using the method inside of a CakePHP element. Also, I installed the Cloudinary files via Composer.

    using "cloudinary/cloudinary_php": "dev-master",

  3. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    Works for me inside an element as well.

    Do you have the following files in your project?

    app/Vendor/Cloudinary/Api.php 
    app/Vendor/Cloudinary/Cloudinary.php
    app/Vendor/Cloudinary/Uploader.php
    app/Vendor/Cloudinary/cacert.pem
    

    Did you modify them in any way?
    Can you try to call this method from elsewhere (controller, regular view, etc.)?

  4. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    How are you loading these in? I haven't modified anything. I can call cl_image_tag elsewhere, but not cl_image_upload_tag. I don't have cacert.pem loading into my project via require or import. To my knowledge that wasn't listed in the docs.

    My folder structure looks like:
    screen shot 2013-09-16 at 12 43 56 am

  5. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    Try to copy only the contents of the src directory to app/Vendor/cloudinary
    Load them using:

    App::import('Vendor', 'Cloudinary/Cloudinary');
    App::import('Vendor', 'Cloudinary/Uploader');
    App::import('Vendor', 'Cloudinary/Api');
    
  6. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    I ended up using the following and it has gotten me passed the cl_image_tag_upload error. Now I'm getting the following.

    Invalid preloaded file info
    Error:
    An Internal Error Has Occurred.
    

    Code reference in view element is below.

    echo cl_image_upload_tag("fileName", array(
                                "callback" => $cors_location
                            ));
                            $preloaded = new \Cloudinary\PreloadedFile($_POST['fileName']);
                            if (!$preloaded->is_valid()) {
                                echo "Invalid upload signature";        
                            } else {
                                $photo->image_identifier = $preloaded->identifier();
                                echo cl_image_tag($photo["public_id"], array(
                                    "format" => "jpg", 
                                    "crop" => "fill", 
                                    "width" => 120, 
                                    "height" => 120
                                ));
                            }
    
  7. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    Looks like $_POST['fileName'] is null which causes an error when trying to construct the PreloadedFile from it.

  8. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    Yep, just realized that.

    Added

    if(isset($_POST['fileName']) && !empty($_POST['fileName'])){
                            $preloaded = new \Cloudinary\PreloadedFile($_POST['fileName']);
                            if (!$preloaded->is_valid()) {
    
                                echo "Invalid upload signature";
    
                            } else {
    
                                $photo->image_identifier = $preloaded->identifier();
                                echo cl_image_tag($photo["public_id"], array(
                                    "format" => "jpg", 
                                    "crop" => "fill", 
                                    "width" => 120, 
                                    "height" => 120,
                                    "name" => "fileName"
                                ));
    
                            }
                        } 
    

    to fix the issue. Now I'm realizing that the cl_image_upload_tag doesn't allow you to pass along an id or class. So much for customizing the look of the input. :(

    EDIT: Man, I must be really sleepy, I just realized that all I need to do is just use existing classes that are assigned.

  9. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    BTW: Thanks for all of the help. It seems to be working now!

  10. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    You can use:

    cl_image_upload_tag("fileName", array("callback" => $cors_location, "html"=>array("class"=>"myclass", "id"=>"myid")))
    
  11. robksawyer commented on Sep 16, 2013

    @robksawyer
    Author

    Beautiful, thanks again.

  12. TalLevAmi commented on Sep 16, 2013

    @TalLevAmi
    Contributor

    Happy to help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions