How to get file size from another web server?

K

Konstantin Mironov

Hi all!

We have the corporate website based on MS IIS 5.0. There's an ASP page for
our customers with the hyperlinks to downloadable files that are hosted on
external web server (in order to reduce corporate internet traffic). It's
demanded to dinamically show the size and the date of creation for each
hyperlinked file on this page. I found a solution know how to do it if the
files are on the same server - with the "getfile([local path]).size" method
of the "Scripting.FileSistemObject". But is it possible anyway if the files
are hosted somewhere else? Are there exist any components/objects for
retrieving file properties remotely via HTTP or FTP protocols?
 
M

Mark Schupp

option explicit

dim xmlhttp
dim targeturl
dim result
dim resultcode
dim resultmsg

targeturl = "http://localhost/kx/logo.gif"

set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open "HEAD", targeturl, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send ""

Response.Write xmlhttp.status & "<br>"
Response.Write xmlhttp.getResponseHeader("last-modified") & "<br>"
Response.Write xmlhttp.getResponseHeader("content-length") & "<br>"

result = xmlhttp.responseText

Response.Write result

Set xmlhttp = nothing
 
K

Konstantin Mironov

Thanks, but it didn't work - it returned "MSXML3.DLL (0x80070005) Access is
denied." error on "xmlhttp.open" method. That was in both cases - when
remote website is in the same network and domain, and when remote website is
in internet. Then I've tried to create "MSXML2.XMLHTTP" instead of
"MSXML2.ServerXMLHTTP" object, and it worked well for the intranet target
url, but failed for the internet one - with the "(0x800C0005)" error on
"xmlhttp.send" method. What can I try to make it working through internet?

ps. Forgot to say - our corporate website (which the code below is running
on) is inside the LAN and published to the internet through ISA server
(installed in integrated mode), but there are protocol- and site-and-content
rules made on it that allow HTTP requests to any destination from the
website's computer account.

Mark Schupp said:
option explicit

dim xmlhttp
dim targeturl
dim result
dim resultcode
dim resultmsg

targeturl = "http://localhost/kx/logo.gif"

set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open "HEAD", targeturl, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send ""

Response.Write xmlhttp.status & "<br>"
Response.Write xmlhttp.getResponseHeader("last-modified") & "<br>"
Response.Write xmlhttp.getResponseHeader("content-length") & "<br>"

result = xmlhttp.responseText

Response.Write result

Set xmlhttp = nothing


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


Konstantin Mironov said:
Hi all!

We have the corporate website based on MS IIS 5.0. There's an ASP page for
our customers with the hyperlinks to downloadable files that are hosted on
external web server (in order to reduce corporate internet traffic). It's
demanded to dinamically show the size and the date of creation for each
hyperlinked file on this page. I found a solution know how to do it if the
files are on the same server - with the "getfile([local path]).size" method
of the "Scripting.FileSistemObject". But is it possible anyway if the files
are hosted somewhere else? Are there exist any components/objects for
retrieving file properties remotely via HTTP or FTP protocols?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top