SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Download Pop-up

  1. #1
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Download Pop-up

    Hi guys!!

    i've noticed this a long time. back then when you wanted to download something from a website, you break into the pages source, and try to locate the absolute path on http://. but now im noticing that most download sites has this piece of code

    Code:
     http://www.website.com/download.php?file=345323
    when the lick is click, the download dialouge box appears. now how can i do this? when using fifefox, the link is not shown, but on IE, the link from where the file is being downloaded is displayed while downloading.

    i wanted to hear some reactions and tutorials if possible.

    Thanks a lot!
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    download.php opens file number 345323 (probably an ID in a database), sends the appropriate headers, then dumps the file to your browser. This makes possible all kinds of things like rate limiting, number of connections limiting, and logging.

  3. #3
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like what header? what if for example, i have here in my database

    id file
    1 image.gif

    and on download.php, u[pon fetching this value i will have this

    Code:
    header("Location: http://www.website.com/myhiddendowlnoadfolder/$file");
    where $file if image.gif...

    is this what you mean? if so, the browser should open theoritically download.php, and not the previous page wherein the link was found. can you give me a cleare example? please sir..
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, download.php should not redirect to the file, it should send the file. What header to send depends on the file being sent... it needs to send the appropriate content type.

    In the case of a GIF image, you'd do

    PHP Code:
    //any type of database operations you want to do before sending go here
    header("Content-type: image/gif");
    readfile($file);
    exit; 

  5. #5
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow, thats a fast reply, thanks sir. can you give me more samples.. you were talking about this a while ago

    "This makes possible all kinds of things like rate limiting, number of connections limiting, and logging."

    i dont bumped into php gurus that often, we might as well make quality time of our meeting..
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  6. #6
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im currently reading php manual for header, but it lacks possible header values and concrete samples. you migth have in there some good links where i can read tutorials about this that i can bookmark..

    thanks again for the help!!
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  7. #7
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you really have to specify everything to the tiniest detail?

    i mean..

    header("Content-type: image/gif");
    header("Content-type: image/png");
    header("Content-type: image/jpeg");

    is there no universal code for images, and applicantions, etc?
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  9. #9
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, no universal codes.

    You can try to guess it with mime_content_type() if your PHP installation has that function available.

  10. #10
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, thank you very much. i guess that 5299 post is no joke!! thanks for helping us get there!! i wanted to be a good php pogrammer like you!!

    chow!
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.


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
  •