Gmail like file upload with jQuery

后端 未结 11 1099
梦谈多话
梦谈多话 2020-12-02 08:36

I would like to upload files just like google mail does. I would want to use jQuery and PHP to do it is there anyway of getting the progressbar etc.?

Here I added a

11条回答
  •  我在风中等你
    2020-12-02 09:21

    In 2018, a website using plain JavaScript can upload files like Google Mail does for mail attachments. A single click can bring up the web browser's file explorer dialog. A separate Submit button is not needed to start the upload. The trick is to use a hidden HTML element.

    Example HTML and JavaScript:

    
    
    
      
      File Upload
      
    
    
      
      
    
      
    
    
    

    PHP code:

    
    

    This works on Internet Explorer 11, Edge, Firefox, Chrome, Opera. This example was derived from https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications

    For a progress bar, see How to get progress from XMLHttpRequest

提交回复
热议问题