Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Progressbar get only the size of first input

Progressbar get only the size of first input

Scheduled Pinned Locked Moved JavaScript
javascriptphpcssdatabasetools
1 Posts 1 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Red Kipling
    wrote on last edited by
    #1

    I have to add progressbar to kleeja upload script I have a three inputs wich contain the files to upload this is the css code for progressbar

    #progress-bar {
    width: 100%;
    background-color: #f3f3f3;
    }
    #progress {
    width: 0%;
    height: 30px;
    background-color: #4caf50;
    text-align: center;
    line-height: 30px;
    color: white;
    }

    and this is the javascript code

    function uploadFile() {
    const fileInput = document.getElementById('file1');
    const fileInput2 = document.getElementById('file2');

    const file = fileInput.files\[0\];
    const file2 = fileInput2.files\[1\];
    
    
    const xhr = new XMLHttpRequest();
    xhr.open('POST', '/index.php', true);
    
    xhr.upload.onprogress = function (event) {
        if (event.lengthComputable) {
            const percentComplete = (event.loaded / event.total) \* 100;
            const progress = document.getElementById('progress');
            progress.style.width = percentComplete + '%';
            progress.textContent = Math.round(percentComplete) + '%';
        }
    };
    
    xhr.onload = function () {
        if (xhr.status === 200) {
            alert('File uploaded successfully.');
        } else {
            alert('Error uploading file.');
        }
    };
    
    const formData = new FormData();
    formData.append('file1,file2', file);
    xhr.send(formData);
    

    }

    i save this file in folder 'progressbar' this is the form to submit for uploading

                    *                           [vars\['lang'\]\['DOWNLOAD\_F'\] ?? '{lang.DOWNLOAD\_F}'?>](#fileUpload)
                        
                
    
            
    
            
    
                vars\['config'\]\['safe\_code'\]){ ?>
    

    vars['lang']['VERTY_CODE'] ?? '{lang.VERTY_

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups