Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Junior Member eli2k's Avatar
    Join Date
    Jun 2003
    Posts
    9
    Member #
    1888
    I seem to be having a little problem organizing PHP files so they link up correctly. Here's what I have:

    HOME DIRECTORY
    |_ embed (htm pages I embed in PHP pages)
    |_ images (all the images)
    All PHP pages here, and style.css

    In the embed pages, if I put pictures in them, they'll go ../images/image.jpg. But if I include them in a PHP file, it's supposed to be images/image.jpg only. What are your ways to get around this without having to recode?

  2.  

  3. #2
    Senior Member ajaspers's Avatar
    Join Date
    Apr 2003
    Posts
    149
    Member #
    1150
    What are you doing, just include()ing the stuff in /embed? That's really not a good idea, because it can easily be a security problem.

    However, answering the question you could use output buffering and pass output through a function. Like so:
    PHP Code:
    function output_handler($text) {
      return(
    str_replace('../images''images'$text));
    }

    ob_start('output_handler');

    // include() or readfile() or whatever here

    ob_end_flush(); 

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    or just reference all of your images relative to the root folder like this:
    Code:
    <img src="/images/file.gif">

  5. #4
    Member nepharo's Avatar
    Join Date
    Jun 2003
    Posts
    73
    Member #
    1729
    transio, without knowing you just helped me in a problem I was having.
    I cannot self terminate, you must lower me into the fire.

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    I'm just cool like that ;-)

  7. #6
    Member nepharo's Avatar
    Join Date
    Jun 2003
    Posts
    73
    Member #
    1729
    :cry: it didn't work.
    the page is not recognizing images relative to the root folder, so
    /images/foo.gif is not been recognized. on the other hand ../images/foo.gif is.
    P.S.images is a folder in the root folder, just in case

    [edit] never mind, it works. You are that cool.
    I cannot self terminate, you must lower me into the fire.

  8. #7
    Junior Member eli2k's Avatar
    Join Date
    Jun 2003
    Posts
    9
    Member #
    1888
    Okay, what about embedding the HTM pages? I tried doing that / thing but it didn't seem to work.

    To ajaspers - Hehe, I have no idea what you are trying to tell me. See, I'm not that good in PHP. You said the include() was a crummy way to do this - is there a better/more efficient way of doing it?

    If I moved all the PHP pages to their own directory, would that work?

    HOME DIRECTORY
    |_ embed (htm pages I embed in PHP pages)
    |_ images (all the images)
    |_ php (all php pages and style.css)

  9. #8
    Senior Member ajaspers's Avatar
    Join Date
    Apr 2003
    Posts
    149
    Member #
    1150
    Yeah, that should work.
    To ajaspers - Hehe, I have no idea what you are trying to tell me. See, I'm not that good in PHP. You said the include() was a crummy way to do this - is there a better/more efficient way of doing it?
    I'm not saying include() is bad but often it is used improperly. Are you just including the file referenced in the query string (?something=blah) without checking anything first? That is a security problem.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:19 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com