检查网站上的文件是否存在 [英] Check if file on website exists
问题描述
在iPhone我想检查,如果一个特定的文件(test.licence)在网站exsists。我的方法(到目前为止)是下载文件,并检查它是否存在于我的Documents目录中。但是,如果文件不存在,Apache会显示一个HTML错误页面(我下载它而不是test.licence)。检查文件大小是一个模糊的解决方案,因为它不同。
on the iPhone I want to check, if a specific file (test.licence) on a website exsists. My approach (so far) was to download the file and check if it exists in my Documents directory. However, if the file does not exists, Apache presents a HTML error page (which I download instead of test.licence). Checking the file size is a fuzzy solution, since it varies.
那么,如果检查,如果一个在线文件存在
请注意,
Stefan
Stefan
推荐答案
通过提交
。当您收到回应时,请检查状态代码是否为200(在那里),404(不是)或其他内容(发生了其他事情)。 NSURLRequest
NSURLConnection
Submit an NSURLRequest
via NSURLConnection
. When you receive a response, check whether the status code is 200 (it's there), 404 (it's not) or something else (a different thing happened).
这篇关于检查网站上的文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!