473,915 Members | 5,813 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 14570
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
1408
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 these files. I map the SMB share on the client, copy these files, and unmap SMB).
1
2759
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
2105
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
6217
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 boxes are set to the same workgroup. Since everything is so locked down now, I'm not sure what's the...
2
2142
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, user3, etc. (there's a lot of them) This web app needs to copy files (Word documents) from our old...
8
2583
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 see if the files in folder "temp" are in there, if not, copy the files that are not from folder...
2
1545
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 possible. Thanks very much in advancem Jerry
0
1314
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. I guess it would be because of the permissions in the IIS for the IUR_Account and the AspNet...
2
3235
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 my perl script as follows:
0
10039
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9881
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
11354
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
11066
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
10542
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8100
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
7256
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();...
2
4344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3368
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.