File Upload Plugin

File Upload Plugin

dianeinfloridadianeinflorida Posts: 8Questions: 3Answers: 0

Is there an example anywhere that saves the image data in the same table as opposed to a joined table?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    I've just replied by e-mail as well, but for completeness and anyone else who finds this conversation, I'll repost my reply here as well :-)

    I don't have any examples that show the saving of the image data into a database as it isn't really something I would recommend. It is generally better to store the file in the file system and a reference to it in the database.

    Furthermore, as the file upload in Editor is asynchronous, if you were to create a new entry, the file couldn't be uploaded as row there the data would be stored is not available until after the file has been uploaded!

    What I would recommend is that you store a reference to the file in the database (for example the file name, or a full path to the file) and store the file in the file system. That way there is no need for a joined table. To do this you would simply not define the db() method for your Upload class, and define a custom action() method that will store the file on the file system and then return the value you want to have the database reference for the file.

    Regards,
    Allan

This discussion has been closed.