473,461 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dowload script

9
Dear Sir,

Hello ! I want to write a script to allow downloading a file from server, which first asks for the path to store the file and then downloads to user's local machine.

Please guide me.

Thanks & Regards,

Naimesh Trivedi
[Email-Removed-Moderator]
Sep 19 '07 #1
2 1742
ak1dnar
1,584 Expert 1GB
You can use this sample script for download files from server.(didn't test)
Then the default download manger for the browser will do the needful for you. Here you will get the save as dialog box. Its completely happening on the browser level. not because of the script, but with the support of headers you are calling to the download manager.
Thanks and good luck.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $file = 'some_file_name_here.pdf';
  3. if($file)
  4. {
  5. header("Content-Type: application/octet-stream");
  6. header("Content-Length: " . filesize($file));
  7. header('Content-Disposition: attachment; filename="'.$file.'"');
  8. readfile($file);
  9. exit();
  10. }
  11. ?>

Welcome to The Scripts !
Sep 19 '07 #2
nbt725
9
You can use this sample script for download files from server.(didn't test)
Then the default download manger for the browser will do the needful for you. Here you will get the save as dialog box. Its completely happening on the browser level. not because of the script, but with the support of headers you are calling to the download manager.
Thanks and good luck.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $file = 'some_file_name_here.pdf';
  3. if($file)
  4. {
  5. header("Content-Type: application/octet-stream");
  6. header("Content-Length: " . filesize($file));
  7. header('Content-Disposition: attachment; filename="'.$file.'"');
  8. readfile($file);
  9. exit();
  10. }
  11. ?>

Welcome to The Scripts !
Thanks it worked. Thanks for the help.

Naimesh Trivedi
Sep 20 '07 #3

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

Similar topics

6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
13
by: dvsbis | last post by:
does anybody have example of file download using java script thanks dave dvs_bis@sbcglobal.net
2
by: marcos | last post by:
sorry, but my english are very bad... how lto dowload visual basic 6.0 from internet?
3
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None...
2
by: bilaribilari | last post by:
Hi all, I am using Tidy (C) for parsing html pages. I encountered a page that has some script as follows: <script> .... var abc = "<script>some stuff here</" + "script>"; .... </script>
2
by: comick | last post by:
Hello all, i have a asp.net c# web app 2.0 I have a pdf generation with a third part sw, but i cant download pdf in a new window, from a folder inside my web site. The code i try to use is...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
1
by: nkamalnath | last post by:
hi, How to dowload a file using javascript.
1
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.