确定DateLastModified通过ASP或ASPNET网络基础JPG图片 [英] Determine DateLastModified for a web base JPG Image via ASP or ASPNet
问题描述
在ASP页面或者页面ASPNET VBS,我想确定日期当远程基于Web的JPG文件创建(或修改等)。例如,一个摄像头拍摄这是FTP-ED的网站。因此,用JPG的URL,我怎么能获得对JPG的属性。
Using VBS in an ASP page or ASPNet page, I would like to determine the date when a remote web-based JPG file was created (or modified, etc). For example a webcam shot which was FTP-ed to the website. Thus, with the URL of the JPG, how can I get to the properties of that JPG.
在code下面我试图检索图像文件并将其保存到我的网站网页,但我得到了 objADOStream.SaveToFile(strSave,2)的路线错误它说,
In the code below I tried to retrieve the image file and save it into my site web, but I get an error on the "objADOStream.SaveToFile (strSave,2)" line which says that
System.Runtime.InteropServices.COMException:写入文件失败。
"System.Runtime.InteropServices.COMException: Write to file failed.".
我知道我已经读/写权限到该文件夹中我经常创建/删除.txt文件存在。
I know I have read/write permissions to that folder as I regularly create/delete .txt files there.
- 您可为什么我不能够保存此文件有何评论?
- 假如我不把它保存在原始文件的属性被保留?
- 或者,也许甚至更好,有更简单的方式来获得照片文件的信息?
下面是code,我拼凑起来的检索和保存文件
Here is the code that I cobbled together to retrieve and save the file
dim strURL, strSave, objXMLHTTP, objADOStream, objFSO
strURL = "http://www.somewhere.com/Photo.jpg"
strSave = Server.MapPath("/xxx/photos/") & "photo.jpg"
objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open ("GET", strURL, false)
objXMLHTTP.send()
if err.number=0 then
if objXMLHTTP.readystate = 4 then
If objXMLHTTP.Status = 200 Then
objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write (objXMLHTTP.ResponseBody)
objADOStream.Position = 0
objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strSave) Then objFSO.DeleteFile (strSave)
objFSO = Nothing
objADOStream.SaveToFile (strSave,2)
objADOStream.Close
objADOStream = Nothing
End If
end if
end if
objXMLHTTP = Nothing
谢谢... RDK
Thanks...RDK
推荐答案
如果你需要的是知道的,而不是发送一个GET请求文件的最后修改日期,发送HEAD请求。在您的code修改 GET
与 HEAD
和后发得
If all you need is to know the last modification date of the file, instead of sending a GET request, send a HEAD request. In your code change GET
with HEAD
and, after send get
objXMLHTTP.getResponseHeader("Last-Modified")
这可能是服务器不发送这些信息,所以你没有办法知道这些数据。
It is possible that the server don't send this information, so you have no way to know this data.
这篇关于确定DateLastModified通过ASP或ASPNET网络基础JPG图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!