【问题标题】:Multiple Image upload using cloudinary使用 cloudinary 上传多个图像
【发布时间】:2020-04-07 16:38:28
【问题描述】:

当我尝试同时上传多张图片时,它会上传同一张图片(首先选择的一张图片)两次。

我使用{multiple:1},但它仍然不起作用。


const uploadToCloudinary = filename =>
  new Promise((resolve, reject) => {
    const publicId = randomize("0", 5);
    // cloudinary.uploader.image_upload_tag(filename, { html: { multiple: 1 } });
    cloudinary.uploader.upload(
      filename,
      {
        html: { multiple: 1 },
        tags: "basic_sample",
        public_id: publicId,
        folder: "vizard",
        eager: [
          {
            width: 200,
            crop: "fit"
          },
          { width: 10, crop: "fit" }
        ]
      },
      (err, image) => {
        if (err) console.warn(err);
        return resolve({
          original: image && image.url,
          w200: image && image.eager[0].url,
          placeholder: image.eager[1].url,
          publicId: image.public_id
        });
      }
    );
  });

【问题讨论】:

    标签: node.js graphql cloudinary prisma


    【解决方案1】:

    Upload APIupload 方法不支持名为html 的字段,用于直接上传文件,而不是创建可供选择的输入字段。

    您可能正在寻找的是 image_upload_tag 或用于多个文件的 jQuery 直接上传功能 - https://cloudinary.com/documentation/jquery_image_and_video_upload#upload_multiple_images

    【讨论】:

      猜你喜欢
      • 2016-01-13
      • 2020-12-25
      • 2021-12-02
      • 2015-12-19
      • 2014-11-29
      • 2019-02-21
      • 2021-03-20
      • 2020-03-02
      • 2019-04-17
      相关资源
      最近更新 更多