开发者

Determine the name of a file to download

开发者 https://www.devze.com 2023-03-09 21:59 出处:网络
I need to download a file from a url which has format similar to http://server.com/sett开发者_JAVA百科ings/files/1 when I paste this url in a web-browser this can determine the name of the file to dow

I need to download a file from a url which has format similar to http://server.com/sett开发者_JAVA百科ings/files/1 when I paste this url in a web-browser this can determine the name of the file to download in this case scheme_563.txt, my question is how I can retrieve the name of the file (which obviously is not included in the url) to download using the wininet functions? currently i am using the HttpQueryInfo function with multiples values like HTTP_QUERY_CONTENT_LOCATION,HTTP_QUERY_CONTENT_DESCRIPTION, etc. but without luck.


According to http://en.wikipedia.org/wiki/List_of_HTTP_header_fields, the Content-Disposition header includes this information

Content-Disposition: attachment; filename=fname.ext

Maybe this optional header is available in the response to a HTTP GET or HEAD request in this case.

Note that the filename may be encoded - see How to encode the filename parameter of Content-Disposition header in HTTP? for a discussion

0

精彩评论

暂无评论...
验证码 换一张
取 消