File Uploads Example
File Uploads Example
Hi All!
I'm building a variation on the file upload example for the Editor.
Can anyone please provide a complete working example as it is not clear to me how the data structure works.
Even just an SQL dump would be really helpful
Just wondering if it would be helpful with the examples section to include
* A zipfile of a the example including SQL dump that could be loaded on a local machine and work out of the box. Sometimes in learning - some of us! - are helped by being able to work back from something that is already working
* If a zip file is not feasible just an SQL dump could be helpful in cases like the upload example
Any comments / help much appreciated
Mike
Answers
Ok, Mike, let me give it a try ...
I had similar difficulties to get this started. I downloaded the example database from data tables somewhere and visualized the data model using MySQLWorkbench. That made it a little easier to understand the relevant relationships.
But here is my own stuff.
1st of all the data model excerpt. You basically have a table "files" that I designed the same way as it is in the data tables examples and then you have link tables to the entities that you upload files for. In my case it is proposals, contracts, offers, (help-)documents and many other things.
The next thing is the JavaScript code:
This is for help documents. The link table as per above is called "document_has_file" linking between "file" and "document"
The Editor instance:
The Data Table
The two small rendering functions "renderFilesEditor" and "renderFilesDataTable" do some specific rendering which doesn't really matter here. The HTML is fairly trivial, too.
And now the PHP:
As you can see both columns of the link table are being used in the PHP Editor instance. Editor sets the used constants as well.
Hope this helps!
rf1234,
Thanks for this. Will analyse and commment. Really hefpful to see it laid out
Mike
rf1234 Made it with your help ! Brilliant!
Here is a simple example for our particular use case
- of course it requires the editor module!
It's rough and only superficially tested but hope it helps somehow
Includes
Mike
DB:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</html>
```