Google Drive API PHP Part 2 | Upload Files On Drive Using PHP

Опубликовано: 25 Март 2026
на канале: Unpossible POG
10,096
59

Google Drive API | Upload Files On Drive Using PHP
-------------------------------
Google Drive PHP API Part 1 :-
   • Google Drive API PHP Part 1 | Display List...  

Stack overflow link :-
https://stackoverflow.com/questions/2...

My Blog code (Modified):-
https://unpossiblepog.blogspot.com/20...

Subscribe my Channel:- 
http://www.youtube.com/user/SanketRoo...

Facebook Page:- 
  / unpossiblens   

Twitter Account:- 
  / unpossiblepog   

Blog:- 
https://unpossiblepog.blogspot.com/ 

Website:- 
https://unpossiblepog.com/ 

Gaming Instagram:- (@unpog.gaming)
  / unpog.gaming  

-------------------------------

In last part, we were able to list files from google drive.
In this part, we shall upload files from our server to google drive.
Let’s jump right into it.
I got a code from stack-overflow, you can copy-paste the code from their link or from my blog. Both links are given in the description.
Create a php file inside a google drive folder which we created last time.
Paste the code inside it within php tags.
We have a vendor folder ready, so remove first 2 lines & import the library.
For client id and client secret. We have to look into credentials.json file.
Also make sure that we first ran quickstart file, the scope was DRIVE.
If not, delete credentials.json file and redo steps again.
Inside json file, we shall find client-id and client-secret.
Copy-paste them inside our code.
In console cloud google site, first select the project.
Then go inside credentials inside APIS & SERVICES.
Select the authentication ID, inside it, add extra URL.
Use the name of newly created php file and save it.
As per code, we shall upload a.png file so change the code accordingly.
Now hit our file in URL.
There is an error.
Change the file path to absolute. Save it.
Add the file path.
After refresh, it will print some array.
And if you go inside your google drive, you will find that image.
Thanks for watching.