Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 7 of 7

Thread: PHP download help

  1. #1
    44
    posts
    Registered User

    PHP download help

    Hi..
    I have a php problem. Im no good at it.. I
    have bought a force download app from FlashDen. I cant get in hold of the authour, so i hope someone else can help me out here.
    It´s regarding the path of the files to be downloaded from, in the php file. As it is now, I have to put all my download files out in the root or in the same folder as i put the download.php file in.
    I have a folder named “images_down” and i want the path to go there.
    here is the php code as original:

    PHP Code:
     
    <?php
        $file 
    $_GET["f"];
        
    header("Content-type: application/octet-stream");
        
    header("Content-Disposition: attachment; filename=\"$file\"\n");
        
    $fp fopen("$file""r");
        
    fpassthru($fp);
    ?>

    So how to put in ánd where my “images_down” folder??
    Hope someone can help..
    Best regardn and new year to your all //Hrbi

  2. #2
    PHP Code:
    $fp fopen("/images_down/$file""r"); 
    sucks that you bought a script like that tho... tons of free examples online.
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  3. #3
    You need to find out the path to your website.
    It's usually something like:
    /home/username/public_html/

    And yeah, I can't believe you payed for that
    Web Design and Web Development blog
    Designer Notice: Browser List for design compatibility

  4. #4
    44
    posts
    Registered User
    Hi guys..

    Yeah you are probraly right. But im a noob at theese things, didnt know there were free scripts. That sounds great. . But thanks for info.

    The code didnt work :-( My code look like this now


    <?php
    $file = $_GET["f"];
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"$file\"\n");
    $fp = fopen("/images_down/$file", "r");

    fpassthru($fp);
    ?>
    My folder "images_down" is located at my root at my server. So if i were to write the hole address it would be"http://www.bilverdy.dk/images_down/

    I hope you can see it

    regards Hrbi

  5. #5
    $_SERVER['DOCUMENT_ROOT'] would give you your home directory. Try This.
    <?php
    $file = $_GET["f"];
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"$file\"\n");
    $fp = fopen($_SERVER['DOCUMENT_ROOT']."/images_down/$file", "r");

    fpassthru($fp);
    ?>
    Web Site Design and Stuff....One day I will get it.

  6. #6
    44
    posts
    Registered User
    Hi guys..

    Thank you for all your help..

    You were right about it was in the $fp = fopen..

    It just worked when i typed in the whole address : http://www.bilverdy.dk/images_down/

    It could probraly be done much simpler but still... I dont get why it did not work with just: "/images_down?

    Thanks again :-)

    //Hrbi

  7. #7
    That script is very unsecure. It should check the MIME Type of a file.
    Member #2 of the "I wont critique Timmytot's designs anymore" club.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012