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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:55:48+00:00 2026-05-13T21:55:48+00:00

I have a list of image paths in my PHP script that I would

  • 0

I have a list of image paths in my PHP script that I would like to pass to javascript whitout rendering them in the HTML page. I mean, I don’t want people go fishing for the path’s when do do a > view HTML source.

<?php
    $images_str = "some/dir/001.jpg|*|some/dir/002.jpg|*|some/dir/003.jpg";
    $images_arr = array('some/dir/001.jpg', 'some/dir/002.jpg', 'some/dir/003.jpg');
?>
<html>
<body>
    <script type="text/javascript">

        var dynamicID = 1;

        /* String */
        _images_str = "<?= $images_str ?>";
        _images_str_arr = _images_str.split("|*|");

        // alert(_images_str_arr[dynamicID]); // OK but renders the image paths in javascript

        /* Array */
        var _images_arr = new Array();
        _images_arr = "<?= $images_arr ?>";

        // alert("<?= $images_arr ?>"); // "Array"
        // alert(_images_arr); // "Array"

        // alert(_images_arr[1]); // "r" from "Array"
        // alert("<?= $images_arr[1] ?>"); // "some/dir/002.jpg" works! but how to use dynamicID??

        // alert("<?= count($images_arr) ?>"); // works as well

    </script>
</body>
</html>
  • 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-13T21:55:48+00:00Added an answer on May 13, 2026 at 9:55 pm

    I don’t want people go fishing for the
    path’s when do do a > view HTML source

    What are you going to do with those image paths in your javascript? If the final goal is to use them as the source of an img tag then you could do absolutely nothing to hide them as tools such as Firebug will show directly all the HTTP requests that the browser performs, so it’s not even necessary to look at the source of the HTML page to obtain the image paths.

    If you intend to do something else with these paths (??) you could use a public/private key encryption algorithm. For example you generate a pair of private/public keys in javascript and you use ajax to send the public key to your server script. The script uses this public key to encrypt the image paths and returns them as JSON array to the client script which uses it’s private key to decrypt them.


    UPDATE:

    Here’s one example of sending the list of paths through AJAX:

    <?php
        header('Content-Type: application/json; charset=utf-8');
        $images_arr = array('some/dir/001.jpg', 'some/dir/002.jpg', 'some/dir/003.jpg');
        echo json_encode($images_arr);
    ?>
    

    and you obtain them in javascript:

    $(function() {
        $.getJSON('/script.php', function(data) {
            for (var x = 0; x < length; x += 1) {
                var imageUrl = data[x];
                // do something with this image url
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this thumbnail list and would like push the image paths (sources) into
I have an image list and would like to add a directory of images
I have a thumbnail image list, all of them have an attribute of 'rel'
I have a list of items like this... <ol> <li> <span></span> <img src="image.png" />
I have the following JavaScript to get a random image from a list of
I'm hacking together a simple php script that will build a list of photo
I have a JList Component and I would like to store paths of the
I have an HTML page (PHP, really) with a table cell that contains a
Given a list of image paths how can I iterate through them and find
Given a list of image paths how can I iterate through them and find

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.