473,800 Members | 2,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Starting a Download

5 New Member
Hi, All,

I'm a bit new to this forum, and not too sharp at designing pages, so please bear with me. I posted a question in another forum and it was suggested that it might be better here.

I have built a web page (HTML) and a PDF document. I can upload these and anything else I need to my ISP server. I know that if there is a HTML link to the PDF document, and someone viewing the page clicks on the link, the PDF will open on their computer and they can right-click and save-as. That's not what I'm trying to accomplish, but may be my only way.

What I want to happen is to have a "download" link in the web page so that when it is clicked it causes a download pop-up to occur that has the run-save-cancel options. I've seen this many times when d/l'ing software, etc., and I imagine you have also. I think the pop-up is titled "Download Manager".

I've searched and searched on the web for download managers, but they all seem to control d/l's inbound to my computer, not the ones outbound.

Any help would be greatly appreciated. If something's not clear, tell me what and I'll to explain better.

Thanks much. Earl
Oct 10 '06 #1
2 1715
ronverdonk
4,258 Recognized Expert Specialist
This may be what you are looking for. It downloads PDFs and other types. You'll have to install it at your server. The last lines show an example of how to call it from a HTML script.
[php]
<?php
// place this code inside a php file and call it f.e. "download.p hp"
// play with the path if the document root does noet exist
$path = $_SERVER['DOCUMENT_ROOT']."/tst/downloads/";
$fullPath = $path.$_GET['download_file'];

if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullP ath);
$path_parts = pathinfo($fullP ath);
$ext = strtolower($pat h_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".$p ath_parts["basename"]."\""); // use 'attachement' to force a download
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$p ath_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd )) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
// example: place this kind of link into your document where the download is shown:
// <a href="download. php?download_fi le=MyDocument.p df">Download here</a>
?>
[/php]

Ronald :cool:
Oct 10 '06 #2
agisoec
5 New Member
Hey, Ronald:
Thanks for the reply. I tried with not much luck. I contacted my ISP and they don't support PHP, so I guess I'm stuck with the old right-click and save-as. I put the code you offered up as a PHP file, but when I linked to it from HTML it said the file type was unknown and wanted to download. That's close, but not what I was hoping to accomplish. Oh, well....good try.
EARL
Oct 11 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2643
by: ian maclure | last post by:
I'm writing a client-server app. Client controls Server which in turn configures and controls a bunch of hardware. I want to be able to start the server from my client. Now in C/C++ one could simply run the appropriate command string through a standard "system()" call which is relatively simple. JAVA on the other hand seems to require something like RMI to do it.
0
2768
by: Katie M | last post by:
Hi, I'm running into a problem where the Microsoft Script Debugger is no longer starting up when it encounters an error or breakpoint. It used to prompt whenever it encountered an error, but is no longer doing so. It doesn't prompt to debug when it encounters an error. It doesn't open when I use the "STOP" command in my VBScript. It doesn't open when I select View|Script Debugger|Open from the IE menu. It just doesn't open. The only...
40
1900
by: Geoff Cox | last post by:
Hello, The following code works with document.getElementById('picture').src = window.src; but not if I increase the index to 1, ie document.getElementById('picture').src = window.src;
2
1532
by: belial | last post by:
Hi! I am new on the group and join in as i am in bad need of help in C programming.I'm a fresher and got to tackle the basics of C in the next few months,so i wonder if anyone on that group could 1) give me the address of some site offering free C compilers,etc on downloads since i got lost in searching 2)some good resources about C programming, codes, how to built functions ... in fact anything that someone starting up programming in C...
3
1732
by: fred bliss | last post by:
Hi All We have a new server running the latest framework, windows server 2003 & IIS 6.0, and we're getting the following error when we try to load the app in IE. Server Error in '/webreporting' Application. ----------------------------------------------------------- ---------------------
3
1211
by: Thomas Wenzl [MVP] | last post by:
Hello, Initial situation: - ASP.NET application. - Users upload a file - that file has to be converted into another file format using a unmanged application that uses a lot of COM components What has already worked? - Upload works
12
4787
by: Prabu Subroto | last post by:
Dear my friends... I am using postgres 7.4 and SuSE 9.1. I want to use auto_increment as on MySQL. I look up the documentation on www.postgres.com and I found "serial" . But I don't know how to create auto_increment. here is my try:
4
10637
by: anne001 | last post by:
Hi For a class, students are going to run an experiment on line. Each time a subject runs, his/her data is appended to one giant text file. Their own data set will be just one line starting with the keyword they gave as identification. The faculty does not want the students to be able to download and see the giant data file. He wants the students to only download and see the data that starts with their own identification tag.
1
2696
by: laredotornado | last post by:
Hi, I just installed the most recent version of ruby and rails on my Fedora Core 5 Linux system. For some reason, my server isn't starting, but I noticed one line upon startup: =Rails application starting on http://0.0.0.0:3000 Shouldn't rails be booting on 127.0.0.1 or localhost or whatever? I didn't read anything about adjusting this setting on the rails
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
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...
0
10274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
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,...
0
5469
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.