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
R

Red Kipling

@Red Kipling
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Progressbar has a value of 100% before upload progress is finished
    R Red Kipling

    I upload a files in my website I have this javascript code integrated to show the progress of upload But the issue is that this bar has value of 100% before the upload is completed How can i resolve this

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

    const file = fileInput.files\[0\];
    
    
    
    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', file);
    xhr.send(formData);
    

    }

    JavaScript help javascript php database question

  • Progressbar get only the size of first input
    R Red Kipling

    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_

    JavaScript javascript php css database tools
  • Login

  • Don't have an account? Register

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