Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
652 views
in Technique[技术] by (71.8m points)

javascript - 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 :)

question from:https://stackoverflow.com/questions/65876523/uploading-pdf-to-cloudinary

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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-


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...