Upload File Google Drive Php

  1. How To Upload Documents To Google Drive
  2. Google

Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free. You can upload, view, share, and edit files with Google Drive. When you upload a file to Google Drive, it will take up space in your Drive, even if you upload to a folder owned by someone else.

Hp 1350xi driver windows 7. Here is the list of HP PSC 1300 All-in-One Printer series Drivers we have for you. If you has any Drivers Problem, Just, this professional drivers tool will help you fix the driver problem for Windows 10, 8, 7, Vista and XP.

Active1 year, 8 months ago

Is there any URL I could use to directly upload to Google Drive? For example, I have a file on my server http://example.com/file.doc and I want to upload it to Google Drive with something like: http://google.com/?upload=http://example.com/file.doc

What's the approach to do this?

Henrik PettersonHenrik Petterson
1,39315 gold badges45 silver badges111 bronze badges

2 Answers

How about this workaround? Unfortunately, there are no URLs for directly uploading files without authorization on Google API. So I propose a workaround. I thought that this method may be easy for achieving what you want to do. Please think of this as one of several answers.

I think that using Web Apps, you can achieve your what you want to do. The flow of this workaround is as follows.

Flow :

1. Sample script

  • Create standalone script.
    • Also you can do this flow at bound scripts. Here, a standalone script is used.
  • Copy and paste following sample script, and save it.

Please run doGet(e). By this, although an error occurs, the authorization process can be done.

WIND TUNNEL TESTS Low Reynolds number wind tunnel tests on a 2D-airfoil were performed, these results were compared to reference experimental data. A NACA 2415 airfoil (Fig. 4), which has become increasingly popular on ¼ scale pylon racers [1], was tested as seen in Fig. The airfoil had a chord length of 200 mm and a span of 600. Low speed wind tunnel testing barlow pdf printer.

2. Deploy Web Apps.

  • On script ediror, at menu bar, select Publish -> Deploy as Web App.
  • At 'Project version:', input string.
  • At 'Execute the app as:', select 'Me'.
  • At 'Who has access to the app:', select 'Anyone, even anonymous'.
  • Click 'Deploy' button.
  • Please copy 'Current web app URL:'. The URL is https://script.google.com/macros/s/#####/exec.
    • You can upload files using this URL.
  • Click 'OK'.

3. Upload a file from URL

  • Query parameter is url=http://example.com/file.doc.
  • You can upload file.doc by accessing this URL https://script.google.com/macros/s/#####/exec?url=http://example.com/file.doc using your browser.
    • In this sample script, the upload file is created on root folder on your Google Drive.

Note :

  • About Web Apps, if you update your script, please redeploy Web Apps as new version. By this, the updated script is reflected.
  • This sample script is very simple. So please modify this to your environment. At that time, if you have any problems, feel free to tell me.
  • In this case, when users upload files using the Web Apps URL, the files are uploaded to Google Drive of owner who deployed Web Apps. Because the script is run as only owner.

If this was not useful for you, I'm sorry.

Edit :

I understand that you want to upload files from URL using php and javascript (I used jQuery here.). If my understanding is wrong, please tell me. doGet(e) of Google Apps Script is required to use these script. At first, please copy and paste doGet(e) and deploy Web Apps. For both script, the file ID of created file on Google Drive is returned as the response.

Upload by php

Upload by jQuery

References :

Edit 2 :

When you want to make users upload files to own Google Drive, please deploy Web Apps by the following flow.

Flow :

1. Sample script

  • Create standalone script.
    • Also you can do this flow at bound scripts. Here, a standalone script is used.
  • Copy and paste following sample script, and save it.

Please run doGet(e). By this, although an error occurs, the authorization process can be done.

2. Deploy Web Apps.

How To Upload Documents To Google Drive

  • On script ediror, at menu bar, select Publish -> Deploy as Web App.
  • At 'Project version:', input string.
  • At 'Execute the app as:', select 'User accessing the web app'.
  • At 'Who has access to the app:', select 'Anyone'.
  • Click 'Deploy' button.
  • Please copy 'Current web app URL:'. The URL is https://script.google.com/macros/s/#####/exec.
    • You can upload files using this URL.
  • Click 'OK'.

3. Upload a file from URL

  • Query parameter is url=http://example.com/file.doc.
  • You can upload file.doc by accessing this URL https://script.google.com/macros/s/#####/exec?url=http://example.com/file.doc using your browser.
    • In this sample script, the upload file is created on root folder on your Google Drive.
  • When users access the URL of https://script.google.com/macros/s/#####/exec?url=http://example.com/file.doc, the login screen to Google is displayed.
  • After logged in Google, the authorization screen is displayed.
  • By authorized it, file.doc is uploaded to user's Google Drive. Because the script is run as each user.

Note :

  • Please deploy Web Apps by only one user. And please share the URL of Web Apps among all users.
  • In this case, users use the browser of each user, because the authorization process is required the browser.
    • If you use this as a HTML, you can put the URL of https://script.google.com/macros/s/#####/exec?url=http://example.com/file.doc as a link.
  • About Web Apps, if you update your script, please redeploy Web Apps as new version. By this, the updated script is reflected.

Edit 3:

Google

In the case of use of Web Apps, when <div> is used, the sample script is as follows.

When users click Upload, file.doc is uploaded to user's Drive. In order to use this sample script, please use the URL retrieved by deploying Web Apps using above 'Edit 2'.

In this case, the login screen is displayed to each user. Users are required to authorize to use APIs after login by click the button on the screen. Is this what you want?

TanaikeTanaike
34.8k4 gold badges18 silver badges36 bronze badges

Take a look at Drive Uploader

you can create your own uploader and have a unique URL for the same which can be distributed among your users.

Hope it helps

Chandrajit KCChandrajit KC

Not the answer you're looking for? Browse other questions tagged google-drive-api or ask your own question.