Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy Response.Write / FTP Question 2

Status
Not open for further replies.

jbs

Programmer
Feb 19, 2000
121
US
This one I think is real easy....but I just can't figure it out. I've spent more time than I care to admit on this one.

I'm trying to have my asp write an FTP link to the users browser so they can quickly download via FTP a file from my web server.

The HTML commands that works fine is as follows:

<br>
Please click on file name to
download file to your computer:
<A target=&quot;&quot; href=&quot;ftp://xyz/ftp.ftp.txt&quot; >ftp.ftp.txt</A>
<br>

When the above commands are executed in my browser a ftp link is shown to the user...and they can successful download the file ftp.ftp.txt from my nt 40 server.

However, when I try to do the same thing for a different file I get a &quot;cannot find server or DNS Error&quot; from my IE browswer.

The code that gives me the above error is shown below:
<br>
Please click on file name to
download file to your computer:
<A target=&quot;&quot; href=&quot;ftp://IDS1/ftp.testftp.txt&quot; >testftp.txt</A>
<br></body></HTML>


The file exists in the ftproot folder...right next to the other folder. Any ideas? this must be obvious...but I don't get it?

Also, here is another question which is more ASP related:
The first set of html code above that works give the user a hyperlink that is as follows:

ftp://xyz/ftp.ftp.txt

However when I try and write the above code via an ASP to the users screen, the hyperlink, which is in error, is as follows:


How can I get my ASP, using the Response.write command, to write the ftp link correctly? Here is the ASP code that causes the problem:

Response.Write(&quot;Please click on the filename to download file to your computer ==> &quot;)
sFTPLocation=&quot;<A target=&#34;&#34; href=&#34;ftp://IDS1/ftp.ftp.txt&#34; >test.txt</A>&quot;
Response.Write(sFTPLocation)


Thanks for the help !!

/jerry
 
just a couple of point.

i cut and copied the last piece of (ASP) code above into msInterDev and after placing the <% and %> at the begining and end of the text and then replacing all but the outermost double-quotes within the
Code:
sFTPLocation
line with single quotes and it does appear to work.
cheers
m Mark Saunders :)
 
Mark and John,

Thank You !!

Some comments:

John: Your reply helped me a great deal last night. I didn't need to use a .com in the HTML command line because I was using an experimental setup in my home in which I have the file that I want uploaded sitting in the default ftproot folder on my webserver. When I first tried using the HTTP method to download a .txt file I ended up seeing the contents of the .txt file in my browser...eventhough I had execution rights turned off. Not sure what happened here but when I changed the file extension to .log (an unrecognizable file extension) my browser immediatly asked where I wanted to download the file (which is what I wanted). So this worked great last night. Only issue here was downloading a .txt. Thank you very much for your help.

Mark: Also, thank you. Although I couldn't get the command to work with the <% >% added to the line (I must have done something wrong) I was able to get the command line to work properly using the single quotes within the outer quotes. I didn't realize that single quotes could be substituted within a string for double quotes in this type of situation.

For anyone that is looking at this, here is the statement that I used to force an ftp download of any file whenever the ftp link is written to the users browser from ASP Response.Write commands:

Response.Write(&quot;Please click on the filename to download file to your computer ==> &quot;)
sFTPLocation=&quot;<A target='' href='ftp://IDS1/ftp.ftp.txt'>ftp.ftp.txt</A>&quot;
Response.Write(sFTPLocation)


/Jerry

 
Jerry,
I'm glad I was of some help. Displayable files like TXT will display in the browser rather than download using HTTP. I don't know how to circumvent this but I don't need to write now. The &quot;non-executable&quot; I mentioned was to keep my ISP from executing the program on the server instead of downloading. I tried FTP but the &quot;darn&quot; thing is apparently set up differently for each ISP e.g. directory has be /Anonymous etc. and when done according to instructions does not work. I don't always use the &quot;easiest&quot; method regardles of performance but I'm not a glutton for punishment either.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top