473,574 Members | 18,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to copy files from web server to client

Hi all,

I need to know if, and how, it is possible to use ASP to download a
file automatically from the web server to the client in a given path.
Is that possible ? Ideally I want a page with a link that when pressed
it will copy a certain file that exists on the web server down to the
client.

Any help is appreciated!

Thanks in advance.

May 23 '06 #1
6 14562
ze******@gmail. com wrote:
Hi all,

I need to know if, and how, it is possible to use ASP to download a
file automatically from the web server to the client in a given path.
Is that possible ? Ideally I want a page with a link that when pressed
it will copy a certain file that exists on the web server down to the
client.

No. This is not possible due to security reasons. All downloads need to
be initiated by the user, and the user gets to pick where the file will
go.

If you are in a WAN, there are other ways to accomplish your goal, which
you can discover by posting to a network administration newsgroup 9I
con't know any offhand - you will need to google for them).

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
May 23 '06 #2
Hi Bob.... think you misunderstood zerbi's question because he does
indeed want it to be user initiated.

Zerbi, you will need to make use of mime type headers and the
binarywrite method of the response object to 'FORCE' a download.

Save the following code to a file and thn pass along the relative
filename with path via querystring you want to download.

By the way, there is no security checks in place here, so amend
accordingly.

Hope it helps you!
<%

Sub ForceDownload(s trFilePath)

Set oFS = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set oFile = oFS.GetFile(str FilePath)
StrFileSize = oFile.Size
Set oFile = Nothing
Set oFS = Nothing

Const adTypeBinary = 1

Set objStream = Server.CreateOb ject("ADODB.Str eam")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadF romFile strFilePath

strFileType = lcase(Right(str FilePath, 4))

' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "applicatio n/msword"
Case ".zip"
ContentType = "applicatio n/zip"
Case ".xls"
ContentType = "applicatio n/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "applicatio n/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp"
Case ".pdf"
ContentType = "applicatio n/pdf"
Case Else
'Handle All Other Files
ContentType = "applicatio n/octet-stream"
End Select
Response.AddHea der "Content-Disposition", "attachment ; filename=" &
StripFileName(S trFilePath)
Response.AddHea der "Content-Length", strFileSize
' In a Perfect World, Your Client would also have UTF-8 as the default

' In Their Browser
Response.Charse t = "UTF-8"
Response.Conten tType = ContentType

Response.Binary Write objStream.Read
Response.Flush

objStream.Close
Set objStream = Nothing
End Sub

function StripFileName(B yVal asPath)
if asPath = "" Then Exit function
asPath = Replace(asPath, "/", "\")
if InStr(asPath, "\") = 0 Then Exit function
if Right(asPath, 1) = "\" Then Exit function

StripFileName = Right(asPath, Len(asPath) - InStrRev(asPath , "\"))
End function

Call ForceDownload (server.mappath (request.querys tring("file")))

%>

May 24 '06 #3
SEOSpecialist wrote:
Hi Bob.... think you misunderstood zerbi's question because he does
indeed want it to be user initiated.


Why do you say that? He used the word "automatica lly" and the phrase " ...
to the client in a given path".

However, I hope you are correct and his problem is solved.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
May 24 '06 #4
It is this:-
I want a page with a link that when pressed....


..... that kinda led me to believe it was user initiated. Maybe we are
both misunderstandin g his needs.

Since you put it like that, I may be wrong also... lol

May 24 '06 #5
Hi there,

It is possible, just create a fso object write the file using this,
give the path and it will be saved to that path directly.

Vivek

May 27 '06 #6
vicky wrote on 27 mei 2006 in microsoft.publi c.inetserver.as p.general:
It is possible, just create a fso object write the file using this,
give the path and it will be saved to that path directly.


Not with standard internet security of the browser.

Yes with a simple wscript on the client,
however that has nothing to do wih ASP.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 27 '06 #7

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

Similar topics

0
1393
by: Hüseyin DEMİRAĞ | last post by:
Hi all, I think that I should ask the question like that. I want to run MySQL on 14 client. What am I do. I try but There is a problem that i can't find... Please help me. Hüseyin DEMİRAĞ İstikbal Furniture Int.
0
530
by: durumdara | last post by:
Hi ! I have some backup files on a server farm. I want to store these local backup files on a backup file server for "safety's snake". These files are compressed zip files with 12 character length password. But my system admin asked me, how can I improve the safety of the copy operation, and the storing (now I use Samba share to store...
1
2740
by: Green | last post by:
Hi, I had a question about how to copy files from server to server on the same LAN. Basically, i need to copy files from "develope server" to the "test server", then eventually to the "production server". But i don't know how to deal with this. Do you have any example code or hint? I appreciate in advance!
3
2094
by: Iwan Petrow | last post by:
Hi I have a Web application. How could I copy a file from one path on the client machine to another path on the client machine? Thanks.
8
6202
by: Chris Strobel | last post by:
I have 2 web servers where I need to write a PDF file and need to keep them in sync. In others words, If the Server1 is getting called to create the PDF, then it needs to copy the PDF to the other Server2 and visa-versa. The 2 server are running 2003. It's a form-based authentication (.NET 1.1) site and I'm using IIS 6 native mode. Both...
2
2129
by: 1388-2/HB | last post by:
On a W2K3 box running IIS 6 I have a web app that implements Forms Authentication mixed with AD (the login page autheticates users against AD & impersonates them with each page request). This means my process identity varies, and is not necessarily "ASPNET" or "IUSR...". My process identity for any given page request will be user1, user2,...
8
2565
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if the folder does not exsist, create folder "www" and then copy folder "temp" and its contents. If the folder "www" is there, look in it, check to...
2
1537
by: PulkitZery | last post by:
Hi I am working on a project and what i need to do is to transfer video files (big in size, >100MB) from client PC to my server. On my server I have WebService running to communicate with my Client Application. Now my question is, How can I upload the files from Client PC to my Server? Any Idea is welcome. Please give me code or example, if...
0
1289
by: sivaramsekar | last post by:
Hi, I have a requirement to copy files (images) from a different server to our web server which has IIS 6.0 and asp.net 3.5. When i try it in my local dev machine i am able to copy and save the files however if i deploy the project in the server i am not able to save the file in the web server and there is no error which throws also. ...
2
3210
by: parmarjm | last post by:
Hi I am trying to copy files from mapped drive (J:\) to a different machine. The perl script is going to run on my machine to copy files from one place to another. File transfer works when i copy files from mapped drive to my machine but when I tried to copy over to different machine throws me an error: Please help me recrify Here is...
0
7820
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8081
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. ...
1
7835
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...
0
6486
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5635
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...
0
5325
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...
0
3759
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...
1
2255
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
0
1084
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...

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.