Closed brodrigz closed 1 year ago
The example, as presented, doesn't actually make sense. The server side must choose how it names files for obvious security reasons. By the time the file completes uploading, the server side of things may look completely different from the client side of things. There is much more here that would need to happen to allow the button to do more than just remove the UI bits from the client side than a simple callback that doesn't cover all possible use cases (e.g. failed network calls).
Also, there is already a mechanism in place to handle successful file uploads and also documentation on how to programmatically remove completed uploads from the list to avoid UI clutter. The correct solution is to update your user interface to show completed uploaded files with appropriate deletion links for your application and not rely on the widget to solve your application's problems with file management. A complete application already has a list of files somewhere, so you need to be updating that list upon successful upload anyway.
The provided example is quite simplistic because the specifics of what happens when a file is removed can vary widely depending on the application.
removeFileServerSide()
may just be sending a token associated with the removed file to the server to free up unused storage space. Also, the callback does not imply that the client should have control over how files are managed on the server, it is simply a way for the client to react to the user's action of removing a file from the UI.
The example, as presented, doesn't actually make sense.
This makes sense because often users need not just to upload files to the server, but, for example, to save a list of uploaded files to a database. What if the user accidentally uploaded a file and we saved it (for example, for a specific order). But the user doesn’t want this, he clicks the delete button and... nothing happens except the line with the file is deleted from the screen. But the file remains in our database on the server and will be considered active.
Therefore, a callback when you click on the Delete button (but only for already uploaded files!) is absolutely necessary. At the moment, I had to insert my own removal function before the lines inforow.remove(); in jquery.fancy-fileupload.js file
@iprahin The delete button simply removes UI. Any other interpretation is wrong. You are supposed to be handling upload completion by updating your own UI elements that are separate from the widget. As I pointed out earlier, the proposed change does not take into account a wide variety of problems that can occur such as network request failures.
Adds 'fileremoved' callback, enabling for more control of removed files.