duangao7133 2013-12-17 20:20
浏览 33
已采纳

如何通过图像发送身份验证标头?

I'm completely new to php but managed to find a script that will produce the HTTP/1.0 401 Unauthorized message box

This is the message box:

I've heard and seen that you can make this message box be sent through an image. How do i go about doing that?

When done, the steps should be:

I post image.jpg The authentication message shows up

I know it involves me having a website (example.com). Then on the website i have a folder (example.com/folder) and in that folder i have the image (example.com/folder/image.jpg). What php script do i put in the folder that will result in the image generating the authentication message?

  • 写回答

1条回答 默认 最新

  • dongmei1988 2013-12-17 21:30
    关注

    As said before in comments, it has nothing to do with PHP.

    The button in your example just set the image URL. But that URL is protected by HTTP Basic Authentication.

    To do this just create 2 files in the image folder : .htaccess and .htpasswd

    And add HTML and Javascript code like the one on the website :

    <img src="" id="downloadImg" alt=""/>
    <input type="button" value="Display Image" id="displayImage" onclick="document.getElementById('downloadImg').src='/protected-folder/image.jpg';"/>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?