Skip to content

Commit feeb6f4

Browse files
authored
Merge pull request #4 from cloudinary-devs/enhance_uploads
Enhance uploads
2 parents 24cb48e + 782123b commit feeb6f4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

upload/tutorial-uploads.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,35 @@
88

99
<body>
1010
<div style="text-align: center;">
11-
1211
<h1>Tutorial Uploads</h1>
1312
<p>Upload your video tutorials here. They are uploaded to the 'training' folder of the 'cloudinary' product environment.</p>
1413
<button id="upload_widget" class="cloudinary-button">Upload Video</button>
1514
<p id="thanks"></p>
15+
<p id="publicId"></p>
1616
</div>
17+
1718
<script type="text/javascript">
1819
var myWidget = cloudinary.createUploadWidget({
1920
cloudName: 'cloudinary',
2021
uploadPreset: 'auto-tutorial',
2122
sources: ["local", "url", "dropbox", "google_drive"],
2223
clientAllowedFormats: ["video"]
2324
}, (error, result) => {
24-
if (!error && result && result.event === "success") {
25+
if (error) {
26+
console.error("Upload Error:", error);
27+
return;
28+
}
29+
30+
// Ensure we only handle the "success" event
31+
if (result.event === "success") {
32+
console.log("Upload Successful:", result.info); // Log full details
33+
34+
// Extract and display the public ID
2535
document.getElementById("thanks").innerText = "Thank you!";
36+
document.getElementById("publicId").innerText = `Public ID: ${result.info.public_id}`;
2637
}
27-
}
28-
)
38+
});
39+
2940
document.getElementById("upload_widget").addEventListener("click", function () {
3041
myWidget.open();
3142
}, false);

0 commit comments

Comments
 (0)