jcampbell1 / simple-file-manager

A Simple PHP file manager. The code is a single php file.
MIT License
914 stars 502 forks source link

Files Re-Submitted After Back Button #111

Open squarewav opened 3 years ago

squarewav commented 3 years ago

If you use "Choose Files", upload a file, view the newly created file and then use the back button, the change event will trigger the file to be re-uploaded again. The fix is to do something like:

        $('input[type=file]').change(function(e) {
                if (this.files.length > 0) {
                        e.preventDefault();
                        $.each(this.files,function(k,file) {
                                uploadFile(file);
                        });
                        this.value = '';
                }
        });

Meaning after the upload(s) just set this.value to reset this.files.FileList to no files.