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 6882375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:14:44+00:00 2026-05-27T05:14:44+00:00

I have a problem. I would appreciate if you can guide me. I have

  • 0

I have a problem. I would appreciate if you can guide me.
I have some images located on a server. In my client code (jQuery) I need to get the images (the actual images, not their links on the server) from the server (by AJAX-php) and show the images on my page. When I receive the images, I do not want them to be saved on the client’s hard disk; I just need them temporarily (maybe the browser can keep them for me for that short time). Can you please help me? I dont know how to implement it with jQuery/php/Ajax and maybe JSON.

my current code is:

<script>
$(document).ready(function () {
    var phpFileName="serverSide.php";
    $.ajaxSetup({
        "url":phpFileName,
        });
    $.ajax({
        "type":"GET",
        async: false,
        "data":{
            "newvar1":"value1",
        },
        "success":function(data){
            var imageName  = data.split('^');
        }
    });

    $imageDirOnServer = "some/Diron/Server/";
    for(i=0;i<imageName.length;i++){
        $("#Cell").append("<div style='background-image:url("+$imageDirOnServer+imageName[i]+".bmp);'></div>");
    }    
});
</script>

and the php Code (serverSide.php):

<?php
for($k=0;$k<3;$k++){
        echo sprintf("%02d",$k+1);
        echo "^";
    }
?>

this code shows 01.bmp, 02.bmp and 03.bmp which are physically located on server, on my webpage.
I want to change it so that the images are taken from the server by my webpage and then are displayed.
I get images from the server when the page is loaded, the reason is that I do not want to have any client-server traffic after that.
I mentioned that I do not want the images to be saved on client machine because I think it is not allowed (without user’s permission) because of security purposes. However, browser’s cache is ok for me.
Thanks.

  • 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-05-27T05:14:44+00:00Added an answer on May 27, 2026 at 5:14 am

    I believe that what you want are inline images.

    This works by putting the image data into the HTML, and can be manipulated from Javascript.

    You end up with an image tag that looks something like this:

    <img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tL" width="16" height="14" alt="My alt text">
    

    So what you need to do is set up an ajax call to a PHP script where you do something like this:

    <?php
    
      // Your AJAX url is script.php?imagename=image.jpg
    
      $image = basename($_GET['imagename']);
      if (!file_exists($image)) {
        header('HTTP/1.1 404 Not Found');
        exit;
      }
    
      $contentType = 'image/jpeg'; // You will need to put the correct type for the file in the string
      $str = "data:$contentType;base64,".base64_encode(file_get_contents($image));
      echo $str;
      exit;
    

    …and when you get the response in Javascript, do something like (for example):

     var newImg = document.createElement('img');
     newImg.src = xhr.responseText;
     newImg.alt = 'My alt text';
     document.getElementById('some_element_that_exists').appendChild(newImg);
    

    Obviously the above code lacks the necessary error checking etc, but hopefully it will get you started.

    If a passing pedant want’s to jQuery-ify my Javascript, feel free.

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

Sidebar

Related Questions

I have a problem finding references to this subject and would appreciate some help.
I have a frustrating problem that I would much appreciate some help with. I
have small problem, and would very much appreciate help :) I should convert byte
I would really appreciate if you could shed light on this problem. I have
I have a problem where I need to line up some DIVs. I made
I have problem with my jQuery code where my Firebug gives me warning: Selector
I have a problem i would like parallelize two for loops with openmp. how
I suppose similar problem would have been discussed here, but I couldn't find it.
I have a little problem where I would like to insert a svn diff
I have a reasonably complex layout problem: I would like to have a main

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.