Download Google Drive file using javascript

前端 未结 1 659
灰色年华
灰色年华 2021-01-16 21:25

I want to download Google Drive file using javascript to my server when i click on Google Drive picker but cannot get the file downloaded. I have been searching if for 4 day

相关标签:
1条回答
  • 2021-01-16 21:45

    TLDR;

    You need to serialize datatable into a URL-encoded string first.


    Explanation

    var datatable = [url, title, type, filesize, fileext,id];

    Here, you're creating datatable as an array

    request.open("POST", "ajax-db-files/copy_drive_file.php?" + datatable, true);

    request.send("datatable=" + datatable);

    Then, in these two lines, you try to concatenate the array directly to the string, which casts the array to a string by calling .join(',') on the array.

    What you need is to serialize the array into URL-encoded notation. If you're using jQuery, try var datatable = $.param({ url: url, title: title, type: type, filesize: filesize, fileext: fileext, id: id]); instead.

    0 讨论(0)
提交回复
热议问题