Get started with jquery-image-upload CDN

MIT licensed

Plugin: Multiple image uploads to server with jQuery selection.

Tags:
  • image
  • upload
  • jQuery

Stable version

Copied!

How to start using jquery-image-upload CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with jquery-image-upload CDN - cdnhub.io</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.min.css" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.cdnhub.io/jquery-image-upload/1.2.0/jQuery-image-upload.min.js"></script>
    <script>
        $(function() {
            $('#image-upload').imageupload({
                url: 'upload.php', // Replace with your server-side script
                dataType: 'json',
                singleFile: true,
                autoUpload: false,
                previewTemplate: '<img src="{url}" alt="{name}" />',
                onError: function(file, errorCode, errorMessage, errorString) {
                    alert(errorMessage);
                },
                onSuccess: function(files, response, xhr) {
                    alert('File(s) uploaded successfully.');
                },
                onComplete: function(files, response) {
                    if (response.result === 'success') {
                        $('#image-preview').html(response.html);
                    }
                }
            });
        });
    </script>
</head>
<body>
    <input type="file" id="image-upload" name="image" />
    <button id="upload-btn">Upload</button>
    <div id="image-preview"></div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</body>
</html>
Copied!
Copied!

All versions