Skip to main content

Can you set the public_id when uploading multiple images?

Comments

2 comments

  • Itay Taragano

    Hi Doug,

    You can choose to keep the original file's name, by setting the use_filename parameter to true while uploading. This way the public ID is automatically using the original name of the uploaded file (normalizing the name to avoid non URL friendly characters and adding a random suffix to promise uniqueness). You can see this behavior by uploading images using the Media Library UI of our Management Console.

    Here's an example (in PHP) of uploading a file, while keeping its file name:

    \Cloudinary\Uploader::upload('sample.jpg', array("use_filename" => TRUE));

    Here'rs an example using cl_image_upload_tag , including multiple uploads:

    <?php echo cl_image_upload_tag("image_id", array("html" => array("multiple" => TRUE ), "use_filename" => TRUE)); ?>

    This will create URLs for your files similar to this:

    http://res.cloudinary.com/<cloud\_name>/image/upload/v1377681437/sample_mzzi4k.jpg

    In addition, your images' public ID can contain one or more folders by adding the  folder  parameter to the upload call.

    For more information:

    http://support.cloudinary.com/entries/25760887-Can-I-upload-files-to-a-folder-while-keeping-their-original-file-names-

    0
  • Doug Lauver

    Thanks! The folder approach will help a lot, actually--I wasn't aware of that possibility.

    0

Post is closed for comments.