简体   繁体   中英

uploading pdf to Cloudinary

I am trying to upload pdf files to Cloudinary through the widget. I assumed that I would just be able to use the same script as the regular images and videos one, but apparently it doesn't like it. when I upload the pdf, it goes through, but the url I am returned with returns no value, it is blank.

here's what I have!

  <h1>Upload Documents for: <%= studentName %></h1>
<button id="upload_widget" class="button">Upload Documents</button>

<script src="https://widget.cloudinary.com/v2.0/global/all.js" type="text/javascript"></script>  
             
<script type="text/javascript">  
var myWidget = cloudinary.createUploadWidget({
  cloudName: 'xxx', 
  uploadPreset: 'ld3l7evv'}, (error, result) => { 
    if (!error && result && result.event === "success") { 
      console.log('Done! Here is the image info: ', result.info); 
      console.log(result.info.secure_url)
      var result_url = result.info.secure_url;
      console.log("result url is " + result_url)
      document.getElementById("url").value = result_url;
    }
  }
)

document.getElementById("upload_widget").addEventListener("click", function(){
  myWidget.open();

  }, false);

 
</script>

anyone know how to change it so I could have it working with PDF as well? Thanks:)

If the upload works and you can find the PDF in your account but upon accessing the link to it you get a 404 then it's most likely due to the new policy described below: https://support.cloudinary.com/hc/en-us/articles/360016480179-Why-does-my-pdf-link-isn-t-working-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM