Is it possible to store the uploaded file by move_uploaded_file to a directory and mark it to be deleted after a few minutes? I’m trying to make a temporary file stay on the server after a period of time then it will get deleted (only if it’s not processed with) so when a file has been uploaded and moved to a directory if it has not been processed (don’t worry about this part, this will be done by me) it should delete the file from the server.
There is no way you can keep the temporary file on the server (without using move_uploaded_file) so basically stored in the tmp directory on the server how can I keep the file when uploaded into the temporary directory (or moved to a directory) and “mark” it to be deleted later on if not processed.
I’ve tried to research how this is possible, but I have not found any type of questions/topics about how to create a temporary file to stay after a limit of time.
EDIT: To clarify, I do not want the file deleted after the script has finished executing after upload.
Follow these steps:
First use the usual move_upload_file function and keep the file on your server.
Now create a new php program to do this:
Now run the above program as a cron once a day.