Can I upload files to a folder while keeping their original file names?




  • Avatar
    Frank Bruce

    If I upload to an folder, it includes the folder in the image URL, but if I check on the Media Library the image is there with the folder in its url, but the new folder has not been created. If I then create the new folder using the create folder button, it creates the folder and any images can then be viewed under that folder.

    It would be nice for the folder to automatically be generated, or is there a way via the API?

  • Avatar
    Itay Taragano

    Hi Frank,

    You can go to your  Settings page and enable Auto-create folders.

    This will automatically synchronize the resources and folders created by the API with the Media library.

  • Avatar
    Robert Jackson

    Is this "folder" parameter available for the PHP API?  I do not see it listed in the API Documentation

    I guess I can just try it.  Also how many images can a folder hold before a new folder should be created?  I'll be processing the images and compressing them by 75% first so the files should be fairly small.

  • Avatar
    Itay Taragano

    Hi Robert,

    While it isn't documented yet, indeed the folder parameter is available for the PHP API as well. Here's an example:

    \Cloudinary\Uploader::upload('my_image.jpg', array("folder" => "my_folder"));

    You can store as many images as you need, there is no limit per folder.

  • Avatar
    Robert Jackson

    Awesome thanks. I am about to try this. My local file structure will be different from my cloudinary file structure.

  • Avatar
    Glenn Goodrich

    So, could I use this to separate staging and production environments? Or do you have another suggestion for that?

  • Avatar
    Itay Taragano

    You can indeed use folders to separate the resources from staging and production environments. 

    However, we usually recommend to have different accounts for staging and production, and copy required images from one account to the other. You can use Cloudinary's Auto-migration feature which you can have your staging account syncing with your production automatically only for your used images. Note that all images of production account will be stored within a folder in your staging account.

    For more information:

    From our Advanced Extra plan, we support having our multi-accounts feature which allows you to manage up to five different accounts via a single login, where all accounts share the master account's usage quotas.

  • Avatar
    ankit parsana

    Hi I am uploading images from the media library and I dont want the appended unique characters for the original file name. Is there any setting for that from the interface.

  • Avatar
    Itay Taragano

    When you upload images via the Media library to the root directory, Cloudinary indeed automatically adds a short random string to the public ID to ensure uniqueness. For more information:

    However, when you upload into a folder, the extra string is not added to the public ID.

    You can also tell Cloudinary to not add the extra string when uploading the API. For more information:

  • Avatar
    Itay Taragano

    You can now set "Use file name in Media Library" in your account's Upload settings page to tell Cloudinary to not add random characters in the root directory either.

  • Avatar

    Hello Itay,

    I use the Auto Upload Feature to get an image.
    I want the image name as Public ID and enabled it in the settings.

    Now I want to use THIS image as watermark and use it with the overlay parameter "l".
    But because I have to choose a folder for Auto upload,
    the Public ID always containts the foldername and "/" in it`s name, which I can not use with the overlay parameter.

    How can I do it this way ?
    I do not want to put hands on the prozess, (the images changes, no solid watermark ! - no renaming e.g. manuell)
    Is there a way to choose the root folder for auto upload ?
    Or is there an "Auto" Rename Function to get rid of the (/) in the name ?

    Thank you so much for your help !


  • Avatar
    Nadav Ofir

    Hi Michael,
    Here's an article that explains how to solve the folders hierarchy matter:
    Moreover, you can map your root directory by putting a slash ("/") inside the "Folder" field.

  • Avatar
    Naw Latt

    Hi, i want to upload image to my created custom folder with C#

    How to populate with C#.

    Here is my code


    var uploadParams = new ImageUploadParams()
    File = new FileDescription("img1", img1.InputStream),
    Transformation = new Transformation()
    var upLoadResult = cloudinary.Upload(uploadParams);
    string publicID = upLoadResult.PublicId;
    string ImageURL = upLoadResult.Uri.ToString();



  • Avatar
    Daniel Mendoza


    If you would like to upload to a specific folder in Cloudinary via C#, add the Folder parameter as part of the ImageUploadParams:


    var uploadParams = new ImageUploadParams() {
       File = new FileDescription("img1", img1.InputStream),               
    Transformation = 
    new Transformation().Width(688).Height(458).Crop("fit").FetchFormat("png"),
      Folder = "folder
  • Avatar
    Khaled BK

    Hi, is there any example using JS ? 

  • Avatar
    Raya Straus

    Hi Khaled,

    You can specify the folder you wish to upload to in the public_id. For example, using formdata- 

    The image will be given the public id "my_folder/mysample' meaning it will be in the folder named "my_folder"


    var formdata = new FormData();

    formdata.append('file', file);
    formdata.append('cloud_name', '<cloud_name>');
    formdata.append('resource_type', 'image');
    formdata.append('upload_preset', '<upload_preset>');
    formdata.append('public_id', 'my_folder/mysample')

    var xhr = new XMLHttpRequest();'POST', "<cloud_name>/image/upload",true);



  • Avatar

    Hello Cloudinary,

    How could I specify the upload folder in Python 3 ?


    @menu_ctrl.route('/', methods=['POST'])
    def upload(gallery):
    gallery= request.args.get('gallery');
    if request.method == 'POST':
    for f in request.files.getlist("file"):
    upload_result = upload(f, folder=gallery)
    return SuccessResponse({}, 201)



    Best regard!

Please sign in to leave a comment.