Help! I'm at my wits end. :rolleyes:

Am in search of a technique to have a .php file simply download
a .zip file (ideally from another arbitrary url, and second best from
a relative path on current server).

I have tried this kind of approach and am having problems.

header("Cache-control: private");
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=\"http://333.333.333.333/thedirectory/thefile.zip\"");

Are the header techniques the only way to achieve the desired
behavior?

Does anybody have a solution they would suggest?

Big thank you in advance!

    if your host your on allows php as a language to use.. its pretty much useless to try and download a php.. but try using zip

      I am glad to have a reply, but I am completely confused by it.

      Maybe I need to be more clear in my question.

      I am trying to have a .php file (and yes my server supports php), download
      a .zip file when the .php file is loaded by the client browser. The .zip file
      is to go to the clients computer and subsequently I wish to display some content in the browser window.

      Or put another way ...

      I am trying to replace a simple link to a zip file
      like ...

      <a href = "http://www.somewhere.com/thezipfile.zip">some text</a>

      with something like

      <a href = "./downloadthefile.php?www.somewhere.com/thezipfile.zip">some text</a>

      and I am looking for some help with what "downloadthfile.php" would have
      in terms of code.

      again, thanks in advance!

      🙂

        I see what you are getting at, you want your script to redirect them to the download loc, am i correct?? if so here is what you need to do

        1. set up some sort of db with a table with the info in it:

        ID | URL

        1 | http://link1.com/file.zip
        2 | http://link2.com/file2.zip

        so on and so forth

        1. have your script query the db SELECT URL FROM files WHERE ID = $fileIdVar

        2. set a var with the url from the db

        3. set the header("Location: $urlDbVar");

        Boom, you have just sent the user to get the file, if you want to get really fancy, you can have your script check to make sure that the file is really there before the download starts, and abort if it is not found. and because it is a download, the user will never really leave your site. Is that what you were talking about, or was it something else???

          ok.. now that makes sense

          why not try this

          download.php?id=2 etc
          then have a header("location: path/to/file/name of file.zip");

            First of all thank you both for your help.

            Yes, I have tried the header("Location ... technique.

            Interesting problem though ...

            The file is downloaded and named "blahblah.php" where blahblah
            is the name of the php file!!!!!!!!

            However the file content is the ZIP content.

            What the hxxx?

            I've been poking around online, and have found others complaining of the same problem

            BTW, I am useing IE 5.1 on a mac.

              AHHHHHHHH!!!
              a mac, that is more than likley the problem, I just tried I just wrote a simple line to try it

              header("Location: ttp://www.crossvilleinfo.com/AcuteScroller.class");
              

              and it works just fine, now I am using IE6 in XP Pro, but i would sat that the mac is the problem, post the entire page and let me try it here. Also what server platform are you on??

              PS, HAD to strip the first h in the address, or it changed my code, damn VB board!!!

                well its not the MAC, (I checked with windows 2000, IE5) had no problem

                AND I checked Netscape on MAC, which also worked.

                Apparently IE on Mac is messed up. I'm gonna see what the heck
                is going on.

                As quick as you are to jump on Mac as being the culprit, I am quick to
                poop on Microsoft, oh well, everybody's doing the best they can! 😉

                Also here's an interesting find ...

                http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;q279667

                It's regarding content-disposition in the header, which I realize is
                different than what we are doing, BUT I have a suspicion that it
                is a related bug.

                  Hey, I am not at all Pro Micro$loth, I have never seen a good program/os(except maybe PPC02) come out of that place. I dont like mac's either, nor any of the flavors of xNIX, I think we all need to go back to PC-DOS, or even better yet Punch Cards 😉 I think that some one needs to marry the features of all of the popular os's and make a new os, write a whole new krnel, and just start from scratch. make it open source so we know that we are not going to get ripped off by the people(299 for XP is a BIG damn rip off, even more so when you have to reload it at least every 2 months) I think we all just need to chunk our computers and all other electronic junk and start back living in caves and try all over again to see how we can do. Well I am just venting

                    uhh DOS was by Microsoft.

                    The NeXT computer was real real cool.
                    Too bad it never caught on....

                    wait a minute... Apple bought it...
                    and then turned it into the new Mac OS/x 10!

                    I don't know why they kept the name Mac. They should change it.

                      Originally posted by jeremuck
                      uhh DOS was by Microsoft.

                      Uhhh, PC-DOS was by IBM.

                        Go baby go!

                        Living in caves? Well I got good news for ya Viper ... its looking like thats where we are headed 😉 . I realize this thread has now taken an abrupt turn but I can't help but respond to your comments.

                        I agree with what you say. I've been a developer with large corps (now independent) for years and have been perpetually reminded of the PRICE we truly pay for the value choices of our capitalistic system.

                        I'm not saying capitalism is the problem, but what my experience has shown me is that everyone is so primarily motivated by the MARKETING objectives, ie. get the product out now (despite the fact that its full of hacks and bugs) rather than focusing on quality, reusability, reliability, etc ... and thus all developers (like you and me) pay a cost as a result of that due to the nature of the system architecture (your code layers are riding on less than acceptable layers which are riding on other crappy layers, ... ultimately riding upon the OS itself which is mismanaged by the monolithic corps with malaligned objectives. and hence kerplunk! we find ourselves in this economy which is an organism spawning more cancerous symptoms by the day.

                        What else is interesting (and unsettling) is the exponential cost imposed on us due to the fact that there are all of us developers depending on a few core systems. The faults of those systems now being multiplied by the number of developers striving to write clean stuff (which unfortunately is intrinsically dependent on the crap that msoft and others have shoveled into the market).

                        In their defense, I gotta say, its real easy to criticize. I can't say my code is perfect. But I shoot as high as I can!

                        And look at the bright side, because of all this stuff you and I got to meet! 😉

                        (and I too find OS X to be encouraging)

                          weedpacket:

                          doh.

                          the rest of what I said is true... soo.... I'm gonna shutup now

                            Originally posted by viper21634
                            I think that some one needs to marry the features of all of the popular os's and make a new os, write a whole new krnel, and just start from scratch. make it open source so we know that we are not going to get ripped off by the people

                            Didn't some bloke in Helsinki do that a few years back?

                              Originally posted by bigpikture

                              And look at the bright side, because of all this stuff you and I got to meet! 😉

                              Once again, you are very right 😉

                                Write a Reply...