473,881 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download file

Ken
How do I download files from the internet server to my computer?

How do I tell the script the correct hard drive folder on my computer to
copy the files to?

After connecting to the internet server, I am trying:

$_SESSION['archive_dir_re ad'] = "/uploaddir/"; // directory on server
$_SESSION['archive_dir_st ore'] = "c:/_picture_file/"; // directory on
computer

copy($_SESSION['archive_dir_re ad'].$_SESSION['picture1'],
$_SESSION['archive_dir_st ore'].$_SESSION['picture1'])

$_SESSION['picture1'] is the file name

How do I address my computer from the internet?

ftp://c:/_picture_file/

or http://c:/_picture_file/

http://ip address/c:/_picture_file/

Thanks for the help.

Ken
Jul 17 '05
13 3681
Ken
header( "Content-Disposition: attachment;
filename=".$_SE SSION['pictures'.$i]);
header( "Content-Type:".$_SESSIO N['pictures'.$i.' _type']);
header( "Content-length: ".$_SESSION['pictures'.$i.' _size']);
header( "Content-Transfer-Encoding: binary" );
readfile($_SESS ION['archive_dir_re ad'].$_SESSION['pictures'.$i]);

I finally was able to save a file from the internet server to my hard drive
thanks to all the help I received from the newsgroup.

For the next person to ask the question about downloading files, a few
pointers.
We know this but do not remember it.

The headers must be before any writing to the display, including html and
echo.
So basically, add a separate page for the headers.

I do have four other questions.
1. How do I define the hard drive directory for the files in the headers?
I added it to the filename, then the file name became the page name,
i.e., file.gif became download.gif download.php is the page file name.
header( "Content-Disposition: attachment;
filename=c:/temp/".$_SESSION['pictures'.$i]); The manual says the directory
name cannot be specified. Is that still true? Any work arounds?

2. Can I download multiple files at one time? Can you suggest a script for
handling multiple files?

3. Is there a way to download the files without going through the file
download box? Open the page and the files download to the specified
directory.

4. Do I need any other headers?

Thanks!!

Ken
Jul 17 '05 #11
*** Ken wrote/escribió (Wed, 25 Aug 2004 04:49:18 -0500):
1. How do I define the hard drive directory for the files in the headers?
I'm pretty sure you cannot. Maybe that's a good idea: if you aren't careful
when browsing the web a malicious site could overwrite any important file
in your hard drive. Just think of all the times you've got a dialog when
about to type "enter" in your text editor ;-)
2. Can I download multiple files at one time? Can you suggest a script for
handling multiple files?
Short answer: no. HTTP connections are not persistent. Once the file is
served, the connection is closed. Even if the connection is keep-alive
type, I guess you need a browser request to serve another fiel. (Not sure
about pipelining though).

Workaround: use JavaScript to open pop-up windows and make it work through
usual pop-up blockers--i.e., make the window.open get tryggered by an user
event.
3. Is there a way to download the files without going through the file
download box? Open the page and the files download to the specified
directory.
See first point. There *are* ways, but you probably need to write an
ActiveX control or signed Java applet.
4. Do I need any other headers?


I don't think so.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Jul 17 '05 #12
Ken
Thanks for the help.

Ken

"Alvaro G Vicario" <al************ ******@telecomp uteronline.com> wrote in
message news:17******** *************** ******@40tude.n et...
*** Ken wrote/escribió (Wed, 25 Aug 2004 04:49:18 -0500):
1. How do I define the hard drive directory for the files in the headers?

I'm pretty sure you cannot. Maybe that's a good idea: if you aren't careful when browsing the web a malicious site could overwrite any important file
in your hard drive. Just think of all the times you've got a dialog when
about to type "enter" in your text editor ;-)
2. Can I download multiple files at one time? Can you suggest a script
for handling multiple files?


Short answer: no. HTTP connections are not persistent. Once the file is
served, the connection is closed. Even if the connection is keep-alive
type, I guess you need a browser request to serve another fiel. (Not sure
about pipelining though).

Workaround: use JavaScript to open pop-up windows and make it work through
usual pop-up blockers--i.e., make the window.open get tryggered by an

user event.
3. Is there a way to download the files without going through the file
download box? Open the page and the files download to the specified
directory.


See first point. There *are* ways, but you probably need to write an
ActiveX control or signed Java applet.
4. Do I need any other headers?


I don't think so.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--

Jul 17 '05 #13
Alvaro G Vicario wrote:
*** Ken wrote/escribió (Wed, 25 Aug 2004 04:49:18 -0500):
2. Can I download multiple files at one time? Can you suggest a
script for handling multiple files?


Short answer: no. HTTP connections are not persistent. Once the file
is served, the connection is closed. Even if the connection is
keep-alive type, I guess you need a browser request to serve another
fiel. (Not sure about pipelining though).

Workaround: use JavaScript to open pop-up windows and make it work
through usual pop-up blockers--i.e., make the window.open get
tryggered by an user event.


IE sucks in this aspect. If you expect that the users would use Mozilla
or some other browser that can handle MIME multipart content, it should
work with the following script:
- - - - - - - - -
<?
define(BOUNDARY , "thisisthebound ary");
header("Content-type: multipart/mixed; boundary=\"". BOUNDARY ."\"");
header("MIME-version: 1.0");

$file1="pic1.jp g";
$file2="pic2.jp g";

$fh = fopen($file1, "r");
$content1 = fread($fh, filesize($file1 ));
fclose($fh);

$fh = fopen($file2, "r");
$content2 = fread($fh, filesize($file2 ));
fclose($fh);

echo "--". BOUNDARY ."\r\n";
echo "Content-type: image/jpeg\r\n";
echo "Content-description: pic1.jpg\r\n";
echo "Content-disposition: attachment; filename=\"pic1 .jpg\"\r\n\r\n" ;
echo $content1;

echo "\r\n\r\n--". BOUNDARY ."\r\n";
echo "Content-type: image/jpeg\r\n";
echo "Content-description: pic2.jpg\r\n";
echo "Content-disposition: attachment; filename=\"pic2 .jpg\"\r\n\r\n" ;
echo $content2;

echo "\r\n\r\n--". BOUNDARY ."\r\n";
echo "Content-type: text/html\r\n\r\n";

echo "<html>
<head>
<title>dl finished</title>
<body>
<h2>Finished downloading</h2>
</body>
</html>\r\n";
echo "\r\n--". BOUNDARY ."--\r\n";
?>
- - - - - - - - -

At least it worked when I tested with Mozilla Firefox, but I couldn't
figure out how IE would handle the multiparts properly.

- Aki
Jul 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6132
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily downloads. It uses fpassthru() and some headers() to send a file to the requesting user. The get.php file that I wrote (the file download module if you will) works like a charm for .ZIP files and .TXT files. However, when .EXE files are downloaded...
0
1838
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog window. Well, thanks to Steve Orr, I have that working. However, I still have a few issues. First, the download dialog does not have the name of the file being downloaded in the "File name" field, instead it has the name of the aspx page that have...
0
1752
by: Rhys666 | last post by:
Basically I have a link that opens my download page and the querystring identifies the type of 'template' Excel spreadsheet has asked to download. The download page reads the querystring, identifies the template required then uses Response.AppendHeader to amend the response to create the file download dialogue. On my local machine this works fine and the download dialogue correctly identifies the file name and type attempting to be...
4
2345
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those dialog boxes that says something like "Do you want to download FILEX.txt?" I want the user to be able to download the file rather than have the file displayed in the browser, because the file will include some characters such as tabs and commas....
1
3596
by: a.r.austin | last post by:
Hello, I am trying to download a few files one after another from a remote server. Problem is that I don't know how to, or if I am able at all, set a time out for download. I don't want to time out whole script, just a part if file won't download in 2mins then skip to the next one. Previously, I had a Javascript implementation with AJAX, this time I thought of doing it in PHP since PHP has far better array functions, I don't have to do...
3
2146
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. The problem is that when you run the program it gets to the: Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
16
3265
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will not print in the username or email amddress of the person doing the download - which I am collecting from a form on the previous page. I can get the name and email address to print out normally, just not into the email sending body. I have...
0
2180
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
0
4022
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
1
47518
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
11098
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10814
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7109
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.