dsorecdf78171 2010-04-27 06:10
浏览 7
已采纳

使用PHP确定是否已替换远程文件?

I have a MySQL database with some URLs in it. One URL per row. Each URL has my script on it. What I am wanting to do, is check if the file is still there via a PHP script. Not check if it 404'd, but rather check if it has been modified or replaced. Is this possible? If so, how would it be accomplished?

I was thinking making the remote file echo some string, and having the local file check the page for that string, but that seems a little inefficient and sloppy.

EDIT: The remote files don't output any data to the remote users, they trigger internal scripts, so remote users would only see a white page. (The checking script would only see this as well)

  • 写回答

5条回答 默认 最新

  • dongqishou7471 2010-04-27 06:22
    关注

    Bulletproof Way

    1. Fetch the URL contents.
    2. Compute the MD5() or SHA1() hash.
    3. Fetch the URL again and check if the hash has changed.

    There are other ways (such as the Last-Modified HTTP header), but they don't work with all servers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)