Question:
I have been working with Wix Dev and I am having trouble obtaining the public URL of a file uploaded through a PDF or image. When I attempt to capture the URL, I receive an invalid path, such as:
Is it possible to obtain the public URL in any way? Thank you very much for your assistance.
Product:
Wix DEVO
What have you already tried:
Here is the code I am using on the frontend:
$w.onReady(function () {
// Add event when a file is uploaded
$w("#uploadButton1").onChange((event) => {
// Get the uploaded file
let file = $w("#uploadButton1").value[0];
// Upload the file to the Wix media library
$w("#uploadButton1").startUpload()
.then((uploadedFile) => {
// Get the URL of the uploaded file
let fileUrl = uploadedFile.url; // Public URL of the file
// Display the URL in the text element
$w("#text14").text = fileUrl;
})
.catch((uploadError) => {
console.error(`Error uploading file: ${uploadError}`);
$w("#text14").text = "Error uploading file.";
});
});
});