Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A <strong>strong</strong> word of advice: upload/attach the file(s) <strong>after</strong> the 'attach target' record has been created.</p> <p>I have a similar situation where i have (well almost the same actually) 'Announcement' object to which i can attach an image or a PDF attachment. My original idea was to allow the posting of the new Announcement (title, category, body, etc) <em>with</em> the file to upload. Now, admittedly i was trying to design for the upload of many files at the same time (and clever responses/validation for failed uploads).. but the point is: this approach was too hard. Do yourself a favour and have the user create the record first, then attach/upload the file(s) after. Having the primary key table record present will also make things easier.</p> <p><strong>EDIT: More info about files and uploads:</strong></p> <p>I use a <code>File</code> object to store files in my db (so yes i will need a binary/image field for the <code>byte[]</code>). Then i have other objects that represent concrete files, like <code>Image</code> and <code>PdfDoc</code> that inherit from <code>File</code> - these include other properties (like Width and Height for the <code>Image</code> type). I have a partial view that renders out a reusable upload control to the detail view which when submitted posts to the <code>AttachImage()</code> or <code>AttachPdfDoc()</code> methods for the particular <code>Announcement</code> (after it has been created - see above). The Service layer looks after storing the files, etc after validation and links the objects. Then the detail view reloads and the attached files are listed ready fo download by the public. (NB: This is heavily summarised btw - i also only allow the edit controls (upload form) on the detail view for authenticated users)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload