FMStudio Upload Module
From FMWebschool Reference
The FMStudio Upload Module allows FMStudio users to create quick upload forms within FMStudio documents. All that has to be done is the selection of a recordset to isolate the specific record to attach the file to, select the specific field, and the Upload Module will do the rest for you!
Version 1.0.0 (July 31, 2007)
- Upload module released with support for extension filtering and file size limits
Version 2.0.0 (October 15, 2009)
- Added FMStudio Pro compatibility to the module
- In a new FMStudio PHP page insert a recordset to find a single record
- This can be either a linked page from a larger list or a constant search during testing
- Select a region on the page that is not within an existing form tag (on a blank page there would not be any form tags)
- Select "Server Behaviors > Modules > Upload > Upload Module"
- Select the recordset, and the three fields to accept information about your upload
- Select a folder to upload the files into, this should be within your site folder
- Make sure that the folder is writable by everybody
- On IIS use the management console to find your target folder, right click, and select write as one of the allowed permissions
- On an Apache server, either use FTP or your local file browser to find the folder and then right click on it. There will either be a "permissions" option or a "properties" option which will then include permissions. Make sure everyone can write to the folder
- Click "Ok" and save the page, then click "Preview in Browser" to open up the page in your browser
- You are done, when you will load the page a form should appear that allows you to upload the file, try it out and a link should appear once the file has been uploaded - click it to verify that you can access it now.
Positioning within the Page
- The upload module must be applied somewhere within the visible area of your design view
- It must not be within a form tag(visible as a dashed red border within the Dreamweaver design view) since it creates its own set of special form tags
- The file is uploaded to the selected folder and is named using its own MD5 checksum calculation as the file name, with a .bin extension
- The renaming of the file at this stage prevents attacks if executable code is uploaded, such as a malicious PHP file which would be easily executable if not renamed to another extension
- Once uploaded, the URL to the file is stored in the database along with its original file name and size. This information is then used through the special "get.php" script within the upload directory to serve the file back to the user.
Accessing the Uploaded File from FileMaker Pro
- To access the uploaded file from FileMaker Pro you can use the web viewer to construct a full URL to the file by appending the URL prefix for your site to the URL fragment that the FMStudio Upload Module has inserted within your record.
Upload Error: x
The following is a list of error messages that can be received from the upload module due to different settings within your configuration. This is a reformatted list from the PHP Manual:
Note: some of these error messages are already gracefully handled by the module and special handling for others will be added with time.
- 0: UPLOAD_ERR_OK
- There is no error, the file uploaded with success.
- 1: UPLOAD_ERR_INI_SIZE
- The uploaded file exceeds the upload_max_filesize directive in php.ini.
- 2: UPLOAD_ERR_FORM_SIZE
- The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
- 3: UPLOAD_ERR_PARTIAL
- The uploaded file was only partially uploaded.
- 4: UPLOAD_ERR_NO_FILE
- No file was uploaded.
- 6: UPLOAD_ERR_NO_TMP_DIR
- Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
- 7: UPLOAD_ERR_CANT_WRITE
- Failed to write file to disk. Introduced in PHP 5.1.0.
- 8: UPLOAD_ERR_EXTENSION
- File upload stopped by extension. Introduced in PHP 5.2.0.
Frequently Asked Questions
Can multiple files be uploaded to the same record?
Currently you can use multiple sets of fields to store each file, but this is not a normalized solution in database design terms. Potentially a separate layout can be used to add portal rows to the current record with this information, however direct entry into portals is not currently supported by the upload module.
Can the file be uploaded directly into a container field?
No, currently the FileMaker API or the pure XML interface do not provide any way to upload a file into a FileMaker container field. Our Grab-It plugin can be used on some server combinations to allow uploading of files into a container field once you have a full URL to the file (which is pretty much what the Upload module provides), however please note that the Grab-It plugin has to be installed within the server itself which is only possible if you have full control of your server (no shared hosting services). Ultimately we hope that using the web viewer and only the Upload Module you should have no need to directly upload files into container fields.