Saving uploaded file to DB in custom handler
<p>I have a <code>DataObject</code> called Document:</p>

<pre><code>class Document extends DataObject {
    private static $db = array(
        'Name' =&gt; "varchar" 
    );

    private static $has_one = array(
        'Document' =&gt; 'File'
    );
}
</code></pre>

<p>And have put this on a front end form. The file uploads correctly and I'd like to save the details to the db.</p>

<pre><code>public function submitDocument($data, $form) {
    $document = new Document();
    $document-&gt;Name = $data['Name'];
    $document-&gt;Document = $data['Document'];
    $document-&gt;write();
}
</code></pre>

<p>Now the Name gets written to the DB however the document doesn't (it's in the file system). I know I can just write the whole thing because the names of the fields are the same in the database however I'd like to write it manually as I'm wanting to do more complex things. I've looked at the attribute that comes in as:<code>{"Files":["19"]}</code> so I've also tried <code>$data['Document']['Files'][0]</code> which logs in my test as <code>20</code> however it's still not saved. I've also manually tried with just <code>20</code> for testing and that doesn't work either. How do I save it?</p>