Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:02:58+00:00 2026-06-09T18:02:58+00:00

I have made a ‘drag and drop’ file upload utility for my users. I

  • 0

I have made a ‘drag and drop’ file upload utility for my users. I made an upload progress bar out of 13 PMG images and animated it using jQuery. That is working quite well if the user just drops one or two files at the same time. But I noticed that if the user drops 10 files the browser makes a request for every image (130 requests). Sometimes the browser takes these images from cache, but sometimes not. So, my solution was to preload the images like this:

function preload()
{ 
    // create object
    imageObj = new Image();

    // set image list
    images = new Array();
    images[0]="img/ProgressBarContent.png";
    images[1]="img/ProgressbarEndEffect.png";
    images[2]="img/0.png";
    images[3]="img/1.png";
    images[4]="img/2.png";
    images[5]="img/3.png";
    images[6]="img/4.png";
    images[7]="img/5.png";
    images[8]="img/6.png";
    images[9]="img/7.png";
    images[10]="img/8.png";
    images[11]="img/9.png";
    images[12]="img/percentIcon.png";
    images[13]="img/ProgressBar.png";

    // start preloading
    for(var i = 0; i < images.length; i++) 
    {
        imageObj.src=images[i];

        if(i == (images.length-1))
        {
        //preloading done, give a visual feedback and droping functionality can be activated 
        hideLoadingOverlay();
        }     
     }
 }

But that did not made any difference.
So I thought I could let a PHP script read the images I need, encode them as base64 and output them as a JavaScript array like this:

$file= base64_encode( file_get_contents ( 'img/0.png') );
echo 'images["img/0.png"] = "data:image/png;base64,'.$file.'";';

That way I could also “hardcode” the images directly into my HTML, right?
I thought that in JavaScript I could do this:

$(".selector").attr("src", images['filename']);

Is this a good solution? Or is there a “proper”/better way?

Thanks!

EDIT:
It does not matter if old browsers do not support this. The scripts are used for a administration area which will only be used by people I know. (And they all have modern browsers.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:03:00+00:00Added an answer on June 9, 2026 at 6:03 pm

    The data URI scheme isn’t supported by IE (or if it is, it’s a very recent addition).

    I’d fix the fact that the browser isn’t always taking the image from the cache, since it should be. Double check you aren’t using a variant of the URI for some calls, and then check that the headers sent are appropriate and giving a max-age of at least an hour, if not more.

    It also never hurts with images for this sort of use to use pngslim or similar to shave off every byte of what’ll be sent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have made quite a bit of progress in my quest to figuring out the
I have made a table users with two fields: username and password. I have
I have made one file say a.php. Now I want some thing like if
I have made an application in which there is a file main.c which uses
I have made a tab bar iOS project, when I received the request to
I have made a binary executable file disassembled using disassembler like IDA Pro. Now,
Have made backup script that does well: makes backup zip-file and then uploads it
I have made a sql database using sql server. This database include images. When
Im have made a navigation bar for the top of site, the final look
I have made a jQuery toggle for a menu that I had in mind.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.