PHP - Get the md5 of remote file?

主宰稳场 提交于 2019-12-30 10:27:49

问题


Is it possible to get the md5 of a file on a remote server? If so how?


回答1:


how about md5_file("http://remotelocation/file")




回答2:


It's not possible without downloading it, or the remote server providing the information (web service, HTML page, etc.)

You can use md5(file_get_contents("http://remotelocation/file")) to download the file and calculate the md5 hash if your PHP installation is configured to open remote streams. But that will download the complete file.




回答3:


Well depends what you mean. There are two ways:

  1. You connect to the remote server and calculate the hash there (like ssh to the server).

  2. Get (download) the file and compute the hash.

Obviously to calculate the hash of a file you have to read the contents of the file.



来源:https://stackoverflow.com/questions/2304081/php-get-the-md5-of-remote-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!