How to delete a file after using move_uploaded_file() - php

Ok, I first uploaded a file using move_uploaded_file(). I then used Dropbox to grab that file and used Dropbox SDK to upload the file to my Dropbox account. I now don't need that file in my File Directory. I only need that file in my Dropbox account. How do I now delete this file with PHP?
My guess would be something like this: delete_file($movie_tmp, $movie_destination);
Thanks!

It's just unlink('page.html');

Related

Error while uploading existing file to google drive using Laravel 5.4

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');

Upload file content to dropbox

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.

Upload folder using Google Drive PHP API

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.

How do I verify that files have been uploaded?

I used this code to find the temporary location of files(pictures) that users(me) upload to my site using a php upload script.
echo sys_get_temp_dir();
returns
C:\Users\a\AppData\Local\Temp
When I look in the temp folder I see some files with .tmp so I don't know if they are the ones downloaded. I'm trying to troubleshoot my PHP upload script. This is because I want to first verify the actual files are downloaded before I use the php move function.
Have a look at is_uploaded_file(). The $_FILES superglobal has information as well. And finally, the whole section about file uploads.
You are looking for is_uploaded_file function.

'pass through' php upload to amazon's s3?

I've seen ways to upload files directly to S3 and I've seen ways to upload a file already on the server. I need to modify the file's name before sending it on to S3, but I don't want to store it locally and then upload it, if I can help it. Is there a way to put it in a buffer or something? Thx.
The file will always end up in the temporary directory first while the upload completes, even before you're able to work with the uploaded file. You get all the file's chunks before, and then it get rebuilt in the /tmp directory by default. So no, there's no "pass-through". But I guess you could re-upload directly from the temporary directory afterwards instead of moving it to another working directory.

Categories