本文介绍了谷歌驱动器保存到不工作(谷歌驱动器API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to make a website that will save a cat into the account of the user and have tried this:

我试图建立一个网站,将一只猫存入用户的账户, < script src =https://apis.google.com/js/platform.js>< / script>
< div class =g-savetodrive
data-src =http://example.com/pug-snores.mp3
data-filename =pug-snores。 mp3
data-sitename =打鼾帕格>
< / div>

<script src="https://apis.google.com/js/platform.js"></script><div class="g-savetodrive" data-src="http://example.com/pug-snores.mp3" data-filename="pug-snores.mp3" data-sitename="A Snoring Pug"></div>

保存图标显示,但不保存到驱动器。

The save icon shows up but it does not save to the drive.

为什么?

谢谢

Thanks

推荐答案

如果你想上传一个带有输入文件格式和/或没有php lib的本地文件,那么...

If you want upload a local file with input file form and/or without php lib would be ...

<!DOCTYPE html>
<html>
  <head>
    <title>Save to Drive Demo: Explicit Render</title>
    <script src="https://apis.google.com/js/platform.js" async defer></script>
  </head>
  <body>
    <form id="GDrive" name="GDrive" enctype="multipart/form-data" method = "post">
      <input type="file" id="file" name="file" onChange="renderSaveToDrive('savetodrive-div', this.files[0].name,'GDrive');"><div id="savetodrive-div"></div>
    </form>
    <script>
        function renderSaveToDrive(namediv, namefile, idfrm) {
            window.___gcfg = {
                lang: 'es-ES',
                parsetags: 'explicit'
            };
            var xhr = new XMLHttpRequest();
            var fd = new FormData(document.forms.namedItem(idfrm));
            fd.append("file_new_name", namefile);
            xhr.open("POST", location.href);
            xhr.send(fd);
            gapi.savetodrive.render(namediv, {
              src: namefile,
              filename: namefile,
              sitename: 'GDrive Demo: Explicit Render'
            });
        }
    </script>
  </body>
</html>

这篇关于谷歌驱动器保存到不工作(谷歌驱动器API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 01:14