view src/uploadcare/uploader2.html @ 3:b016e4b7c8da default tip

add read_me
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 12 Jul 2025 12:51:36 -0600
parents 8f4df159f06b
children
line wrap: on
line source

<!doctype html>
<html lang="en">
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<style>
		</style>
		<script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
		<script>
			'use strict';
			var UPLOADCARE_PUBLIC_KEY = '718cc25ec1508ca5801d';
			var UPLOADCARE_TABS = 'file camera url facebook gdrive gphotos instagram';
			var UPLOADCARE_DO_NOT_STORE = true;
			var UPLOADCARE_IMAGES_ONLY = true;

			let upload_result = null; /* For debug. */

			function upload() {
				// openDialog() apparently returns a promise, that, when done, returns another promise
				// that, when done, returns object with file information. At least in case of success.
				uploadcare.openDialog().done(
					function( promise2 ) {
						promise2.done(on_uploaded);
					}
				)
			}

			function on_uploaded( file ) {
				upload_result = file;
				if( file && file.cdnUrl ) {
					let result = document.getElementById("result");
					result.src = file.cdnUrl;
				}
			}
		</script>
	</head>
	<body>
		<p>top</p>
		<p>
			<button onclick="upload()">Upload</button></br>
			<img id="result"></img>
		</p>
		<p><a></a></p>
		<p>bottom</p>
	</body>
</html>