How to make an absolute URL?

Discussion in 'PHP' started by bobby9101, Jun 10, 2007.

  1. #1
    Hi, I am working on file uploads and I ened to save the new photo location in a database.
    So what i want to do is, move the file one folders up, and then make that an absolute URL to save into the database.
    Example:
    Current Page: site.com/photos/upload/photo.php
    Where I want the photo to go: site.com/photos
    What I want saved to the database: site.com/photo/photo.jpg
     
    bobby9101, Jun 10, 2007 IP
  2. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    /your/web/path/site.com/photos/save.jpg

    ?
     
    HypertextFever, Jun 10, 2007 IP
  3. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh sorry, i wanted it to be able to used on more than one site of mine, thats why I can't specifically set the URL, I need the script to do that based on the current URL
     
    bobby9101, Jun 10, 2007 IP
  4. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ahh, you could:

    1. Create a config variable for the user photo path (full server path)
    2. Use this: $photo_path = $_SERVER['DOCUMENT_ROOT'].'/photos';
    3. Try relative pathing: ../../photos (etc.)
     
    HypertextFever, Jun 10, 2007 IP
  5. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok, so if my page is: http://site.com/upload/photo.php
    And I do $_SERVER[SCRIPT_FILENAME] it returns something like:
    home/fawfw/awfawfaw/fwaaf
    How do I get the actual url like:
    http://site.com/upload/photo.php
     
    bobby9101, Jun 11, 2007 IP
  6. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks all!
    I got what i needed
     
    bobby9101, Jun 11, 2007 IP