Upload files
Upload files
One thing I don't understand about loading files....
The official example is here:
https://editor.datatables.net/examples/advanced/upload.html
As I understand there are two tables: users and files.
What I can't understand, is why I need two tables. Since for each user corresponds a file, wasn't it better to put the columns 'filename', 'filesize', 'web_path' and 'system_path' directly in the user table?
The same goes for multiupload: https://editor.datatables.net/examples/advanced/upload-many.html
Three tables are used here...wouldn't just two be enough?
I mean, saving a table I find it interesting.....
Answers
Not really, there is "anything" and "files"
...because it isn't so. "Anything" can have zero to very many "files".
Here is a little pic from my data model:
What you can't see in the picture are the 7 more "anythings" in my model that can have zero to many files ...
In addition to that, I think the key thing to be aware of here is that the file upload is async to the rest of the form. So when you select a file it sends it to the server at that point, which stores the file and information about it somewhere, and then returns a reference to the file (usually a primary key integer). That is what is then submitted as part of that main form.
For this reason, it is important to have two different tables in the database. You are right in the simple 1:1 case it is a little redundant, but it is far more flexible, allowing the same code patterns in our libraries to be used for 1:many as well, and it means that the "meta" information doesn't need to be passed back and forth between the client and server more than needed.
Allan