How to receive php image data over copy-n-paste javascript with XMLHttpRequest

后端 未结 4 1460
轮回少年
轮回少年 2020-12-15 13:14

I try to make an image-upload functionality similar to the one GMail uses. You copy (CTRL-C) an image from your desktop and paste (CTRL-V) it onto the website. The image is

4条回答
  •  悲&欢浪女
    2020-12-15 13:41

    you copy (CTRL-C) an image from your desktop and paste (CTRL-V) it onto the website.

    No, that is impossible. What you can paste is e.g. screenshots and images from the web, that's what gmail does.

    Your biggest mistake is using FileReader when you already have a file, the $_FILES array is filled when there is a proper HTTP upload not for ad hoc base64 POST param. To do a proper HTTP upload, you just .append() a file or blob object (Files are Blobs).

    This is a stand-alone PHP file that should just work, host the file, open it is a page, take a screenshot, then paste it while on the page and after a few seconds the image should appear on the page.

    
    
    
    

提交回复
热议问题