SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2002
    Location
    jupit3r
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do 'mask' the image directory?

    I'm lost on this one.

    I want to display an image (the path is pulled from mysql). Instead of www.site.com/images/blah.jpg I'm thinking about:
    www.site.com/index.php?id=blah.

    The database looks like:
    id - image path - author - approved
    1 /images/blah.jpg Joe 1 (yes)

    So far I do a (select * from points where approved=1). Can I do a 2nd mysql query to take the approved entries and display the image soley based on the id # (revealing the actual image name is ok)? If so, an example would be greatly appreciated!

    thx
    -D

  2. #2
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My advice would be to store ONLY the filename, then when showing the image, use something like:

    <img src="images/<?=$image?>" title="Image" width="x" height="x" border="1">

    or, if you're listing links to the images where users can click on them... to prevent them from seeing the full path in the status bar....

    <a href="images/<?=$image?>" onmouseover="window.status='';return true">

    hope that helps...

  3. #3
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I think I am missing something. You want to make sure the image is approved and then mask the directory structure of the image correct?

    You would simply do a SELECT * FROM points WHERE id='id' and then put it in an array and open the image location and spit out the image.

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    Perth, Australia
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    f00, this hopefully answers your thread's title, "How do 'mask' the image directory?".

    You can display a file without it's path name by sending a raw header:
    http://www.php.net/header
    NOTE: There are problems that exist with this technique, so be sure to read the php.net documentation carefully; the example code is only there to point you in the right direction.

    Here is the example code:

    PHP Code:
    // showImage.php - using header(), displays an image - uses $_GET['image'] to display relevant image
    $image $_GET['image'];
    header("Content-Type: image/jpeg");
    header("Content-Disposition: inline; filename=$image");
    readfile("$image"); 
    To view the image directly, point your browser to www.yoursite_url.com/showImage.php?image=your_image_name

    you can also display the image within an HTML page like so:
    Code:
    <!-- output.html - calls showImage.php to display specified image -->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<title>Show Image</title>
    </head>
    <body>
    <img src="showImage.php?image=perth-01.jpg">
    </body>
    </html>
    Does this answer your question?

  5. #5
    SitePoint Member
    Join Date
    Oct 2002
    Location
    jupit3r
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the ideas all!

    The approval is done by me kinda manually after reviewing the image. I'm trying to avoid the user right clicking | image properties | discovering the path (www.site.com/images/blah.jpg.

    I think the header idea may work. I'm not familiar with that concept so it looks like there is some readin' to be done.

    thanks again! I'll report back with my progress (or lack thereof).

    -d


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •