Answer the question
In order to leave comments, you need to log in
Node.js Uploading files to the server. What to do with old unsaved files?
Greetings.
Server on Node.js. Express 4.0 is used.
There is a page with a form on it through which files are loaded. After downloading, the files are placed in a temporary folder temp (for each user a separate temp folder). If the user clicks the Save button, the files will be moved to the user's folder.
Question: if the user uploaded files, but did not click Save, but simply left the page. What to do with these downloaded files in the temp folder ? How to trace such files and delete them?
Answer the question
In order to leave comments, you need to log in
Decide on the time after which the files should be deleted. Periodically clean out obsolete files with a script. In order not to drive through a huge directory tree, when loading a file, you can make a record of the path to it and the time it was loaded into the database. Accordingly, from the database and take a list of files to be deleted (selection by creation / expiration time). Well, do not forget to delete records from the database in the process of bypassing it with a script and when the user clicks the "Save" button, that is, along with deleting the file from the directory.
Use jquery, a method that fires when the window is resized
$(window).resize(function() {
var dw = $(document).width();
//твой код
});
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question