Upload folder into google drive folder using PHP . #167309
-
Select Topic AreaQuestion BodyI need to upload the "My Folder" folder, which contains multiple folders with their contents (images/...), to Google Drive using PHP. I know I can create a folder and upload files to it. But I need to upload the folder directly to Google Drive. Is there a way to do this ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
hey bro, you can work with python, if you want to use other languages, you can, but python is very easy. you will need cloud api. create project in python:
in php: using compose Code ChatGPT
Upload folder
🥱 |
Beta Was this translation helpful? Give feedback.
-
Okay, so you want to upload a whole folder to Google Drive using PHP, right? The thing is Google Drive's API doesn't actually have a single way to upload an entire folder with all its subfolders and files in one go. Instead, you'll need to write a PHP script that basically mimics what you'd do manually it'll have to go through your local folder, create each subfolder one by one on Google Drive, grab the ID of that new online folder, and then upload all the files into their correct new homes recursively repeating this for every nested folder, It's a bit of a manual process in code, but totally doable by breaking it down into those steps. This post might help you get started with the basics like authentication and single file uploads: How to Upload to Drive with PHP, but you'll still need to implement the recursive logic to handle the full folder structure |
Beta Was this translation helpful? Give feedback.
-
You can’t upload an entire folder directly to Google Drive using PHP in a single action. Instead, you must recursively create folders and upload files one by one using the Google Drive API. First, create the folder structure on Drive via the API, then upload each file into its corresponding Drive folder. There’s no built-in PHP method to upload a folder (with contents) in one step. |
Beta Was this translation helpful? Give feedback.
Okay, so you want to upload a whole folder to Google Drive using PHP, right? The thing is Google Drive's API doesn't actually have a single way to upload an entire folder with all its subfolders and files in one go. Instead, you'll need to write a PHP script that basically mimics what you'd do manually it'll have to go through your local folder, create each subfolder one by one on Google Drive, grab the ID of that new online folder, and then upload all the files into their correct new homes recursively repeating this for every nested folder, It's a bit of a manual process in code, but totally doable by breaking it down into those steps. This post might help you get started with the basics…