How to download a file (with browser) using fsockopen() ?
Posted: Sun Feb 03, 2008 10:30 am
Hi
I have been working on this download script for quite a while, and I just can't find how to download a remote file via a user's browser using fsockopen.
Basically I am wondering if anyone can just give me a simple working example on how to use fsockopen() to fetch a file on a remote server, and then pop up a save dialog box in my browser. For example, let's say I want to download this file from here:
Instead of putting this directly into my browser and then being prompted to save it to my pc, how can i use fsockopen() to fetch the file, and get the same prompt on my browser? E.g. I want to be able to do
I know that this does not seem the most obvious and easy way to do it, but i simply cannot get a file to download myself using fsockopen. I specifically want this function, as I need to POST headers to the server and I haven't as yet been able to download a file using it, without it being corrupt, or the connection hanging. I just can't figure it out, and I'm getting a bit tired with it!
I don't need a whole hand-made script, I just need the part where fsockopen will download this file. Perhaps a working function that would do it. Please try not to use classes or objects because I haven't quite figured out object-oriented programming yet!!
Also, I would like if you can do it via HTTP 1.0 because I know HTTP 1.1 is tricky, and might require a chunk decoder.
Thanks to anyone who can help.
I have been working on this download script for quite a while, and I just can't find how to download a remote file via a user's browser using fsockopen.
Basically I am wondering if anyone can just give me a simple working example on how to use fsockopen() to fetch a file on a remote server, and then pop up a save dialog box in my browser. For example, let's say I want to download this file from here:
Code: Select all
http://remotedomain.com/file.zipCode: Select all
http://localhost/index.php?url=http://r ... m/file.zipI don't need a whole hand-made script, I just need the part where fsockopen will download this file. Perhaps a working function that would do it. Please try not to use classes or objects because I haven't quite figured out object-oriented programming yet!!
Also, I would like if you can do it via HTTP 1.0 because I know HTTP 1.1 is tricky, and might require a chunk decoder.
Thanks to anyone who can help.