Uploads without Records?
2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 27, 2014 (RSS)
Hello, All -
This is one of those "thinking out loud" queries which may or may not sound silly depending on your point of view!
As we know, items are uploaded with CMSB via a parent record in the editor. The uploaded file maintains a link to that record in the database.
What I want to know is, would be plausible to create an image uploader that completely bypasses record creation? In other words, can I upload a file without assigning it to a record?
The only really important detail that the record holds is the user number of the person who created it. If this were instead added to the upload (perhaps using one of the 5 info boxes), there would be no need to maintain a link to a parent record.
I see a number of advantages to this approach. If I were creating a gallery, for example, there is really no need to create a record every time someone uploads a photo. It's the picture that's important, not the record.
Each upload has the following table fields which determine it's lineage: tableName, fieldName and recordNum. These values could be assigned during the upload.
In the case of recordNum would it be possible to assign a value of 0 without breaking it? That way an image could be added directly to the cms_uploads table without the need for a parent record.
:0/
Perchpole
By Dave - November 27, 2014
Hi Perch,
Interesting idea. There is a method used to store images without nums, it's a field called "preSaveTempId" and it's set when images are uploaded during record creation (when no record exists yet) and then they're assigned to the record when it's saved (or erased after 24 hours or some duration of time).
So you could just upload files, but the code that "cleans up" unassigned uploads might erase them after a while.
What about having a "Single Record Editor" with one upload field and lots of uploads in it? Or what about a Multi-record editor for "Photo Gallery" and a record for each "category" with one field for uploads?
If you want to get all the uploads for a section you can query the upload table directly, it's hidden but you can see the fields here:
admin.php?menu=database&action=editTable&tableName=uploads
The issue with querying it directly is you'll be getting the mysql data and not all the full image paths, but that method might work for you.
Let me know what you think.
interactivetools.com