How to get the full URL instead of the UUID

I need to get the full URL into the form field instead of just the UUID. I’m using Webflow forms that publish into a Google Sheet.

e.g. I need this:

[https://ucarecdn.com/4a277d1d-d0e2-4f5d-9bea-6e8361f44c88/AltJAnAwesomeWave.jpg]

Rather than this:

[https://ucarecdn.com/4a277d1d-d0e2-4f5d-9bea-6e8361f44c88/]

Hi @shout,

By default, the value attribute of the widget’s hidden input element is populated with a URL of the uploaded file without the file name after the trailing slash. If you need it to be added as well, you can do this by adding the following JS snippet:

var widget = uploadcare.Widget([role=uploadcare-uploader]);
widget.onUploadComplete(function (fileInfo) {
  widget.inputElement.value = fileInfo.cdnUrl + fileInfo.name;
});

Try adding it at the bottom of your page’s , before the closing tag.

Hi @Alex

Thanks for the JS snippet. I added it to the page before the but the URL’s are still coming in without the file name. Example: https://ucarecdn.com/989f2add-4e40-4c0c-8c91-07bcd0cf2705/

CleanShot 2022-06-08 at 21.39.59

Sorry, there was a typo in this line:

It should be:

var widget = uploadcare.Widget("[role=uploadcare-uploader]");

Since you have more than one widget on your page, you’ll need to adjust the code snippet so it can work properly with multiple widget instances:

var widgets = uploadcare.initialize();
widgets.forEach(function (widget) {
  widget.onUploadComplete(function (fileInfo) {
    widget.inputElement.value = fileInfo.cdnUrl + fileInfo.name;
  });
});
1 Like

You’ve rocked my world. Thanks @Alex

I really appreciate the time you’ve taken to help me out. :smiling_face_with_three_hearts:

1 Like