#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    NYC, USA
    Posts
    17
    Rep Power
    0
    HI all,
    The problem I am encountering is something like this.
    I've uploaded a zip file which i want all my friends from my site. When they click in the link, i want the download to take place.

    my code goes like this :

    header("Content-type: application/zip");
    $file_open = fopen ( "C.zip", "rb" ) ;

    getenv("REMOTE_ADDR"), 80 ) ;
    while ( !feof ( $file_open ) )
    {
    echo fgetc ( $file_open ) ;
    }
    fclose ( $file_open ) ;

    the file also gets downloaded, but it does not open as an valid archive (ie i'm not able to open the file after the download.)

    Someone finding anything wrong with the code or with an alternative solution pls reply

    Thanking you in advance.

    ntrilok

    ------------------
    If not U, who?
    If not now, when?
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    Can't you just print out a link to the zip file? when the user clicks on it, it'll start downloading...
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Newark, DE, USA
    Posts
    39
    Rep Power
    15
    The code you pasted is trying to treat your zip file as ASCII, which it is not. You can only use fgetc() on text.

    You'd really benefit more from a hyperlink to the file, but if you must push the file out via a script, try something like this ...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php
    $fp = fopen("myFile.zip", "r");
    header("Content-type:application/zip");
    fpassthru($fp);
    fclose($fp);
    ?>
    [/code]

    ------------------
    ~Chris
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    NYC, USA
    Posts
    17
    Rep Power
    0
    Thank you wesley for your code.
    But there is still a problem .
    Your code enabled me to download the file but then it was the .php3 file which got downloaded and not the zip file. this is slightly confusing.



    ------------------
    If not U, who?
    If not now, when?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    NYC, USA
    Posts
    17
    Rep Power
    0
    hey thanks a lot
    don't mind the previous reply
    the code worked
    thanks a lot
    actually it was a ssamll bug


    ------------------
    If not U, who?
    If not now, when?

Similar Threads

  1. Download WAV files without timedelay ?
    By BlackSheep in forum PHP Development
    Replies: 9
    Last Post: February 24th, 2004, 04:58 PM
  2. Download Problems in IE
    By mrsarun in forum Windows Help
    Replies: 3
    Last Post: February 18th, 2004, 03:41 AM
  3. c problem parsing code
    By mharvey in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 12:02 PM
  4. fread problem: doesn t compile php code
    By ghorghor2002 in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 05:25 AM

IMN logo majestic logo threadwatch logo seochat tools logo