I want to upload a folder of files to Google Drive, using the PHP API. I can upload a single file to my Google Drive, but can't seem to upload a folder of files...e.g. a folder containing some Word documents and PDFs. Does anyone know if this is possible?
Files: insert Insert A new file
In instances like this the documentation can be a big help. File.insert is for inserting A file as in one singular. If you want to insert more then one I suggest you look into using a loop and looping over each of the file you would like to upload.
Tip:
setting the mime type as follows creates the initial folder
mimeType = 'application/vnd.google-apps.folder'
Note the file id when that is created and set the parent of the files up upload to that and they will be uploaded into that directory.
Related
I'm using Laravel 5.4. I'm trying to upload file to google drive using
Storage::disk('google')->put('file.txt', 'hello world')
using above method file named 'file.txt' is created in Google Drive folder. but i have to upload an existing zip file.
I'm using the below code to upload the zip file in google drive.
Storage::disk('google')->put('RandomFileName.zip', storage_path('app/backup.zip'));
Zip file is created but with corrupted file having size in 50 byte sometimes.
I've solved this issue by
Storage::disk('google')->put('FileName.zip', file_get_contents("fileLocation"));
Previously I was not including file_get_contents() that's why it wasn't including the content of the zip file.
As per the documentation for Laravel File Storage you should use the copy or move method, not put.
So your code should be something like:
Storage::disk('google')->move(storage_path('app/backup.zip'), 'RandomFileName.zip');
I want to upload file that I am generating in my app. It looks like I can upload file if I will provide path to the file, or url where the file is, but I have only content of the file. Is there a way I can upload that content dropbox ? I am using third party php sdk
I solved this by creating temporary file that will be uploaded and then deleted.
This is not the first time I am doing file upload using CI. However in this particular case I want to upload images or files to shortcut folder created at project root. This is what my project root looks like in following image:
So basically what I had been trying to do is using php filesystem function is_dir('goku') (goku is shortcut folder as shown in above image that links to C:\Users\Name\Desktop) and if true then create a sub-folder inside it and insert the image or file in that sub-folder. However I didn't find any way to make the shortcut folder recognize as directory and returns file upload error -The upload path does not appear to be valid. Upload works fine on other folder. I know that php is not recognizing the shortcut folder as directory because on running is_dir('goku') returns false. I have gone through all probable solutions but now again back to where I started. Any helpful hints regarding this is highly appreciated. Thank You!!!
Using the library Codeigniter
library upload single file and multi file
Easily upload .
I have code that relies upon a certain file naming convention. When I stopped working locally and made a new database and setup online and went to upload the images for the posts. Wordpress adds a -1 or -2 to my images even though it is a fresh db and fresh wordpress install.
The naming conventions I have are like so..
cover_somename.jpg
cover_somename_bg.jpg
Why would it make my files like cover_somename_bg-1.jpg when there are NO DUPLICATES in the media library. How can I turn this renaming feature off/ rename the files myself.
When you upload image on local it will create move image to upload folder. And while you moving project to live you create new data base you have only remove the image name from the data base table.
But you image still remain on Upload folder under the month folder that you have added
When you upload the same file name on live server on same month then it will check for "if file already exist or not if already exist then it will rename new uploaded file as you get.
you create new data base so you old image wouldn't display on admin so you need to clear the folder under the upload folder then it work fine please try once.
Ah images aren't in the DB turns out they are in uploads folder and if the uploads folder has images but its a fresh install the media library will be empty but will act like it has those files and renaming will occur.
I was searching for this but i can't find anything like this.I'm new to PHP, I want to have a backup of all my pictures in specific directory.
I want when i click on link it collect all the images in that directory and compress them into a zip file, then it give me a download link for them.
I saw an answer before for how to (download multiple files as zip in PHP) but i don't know how to get all the images full names in this directory and merge them with the commands for zipping
I wish that's possible.