Commit 003f6d63 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature #5571 / File Upload: save filesize and mimetype automatically in...

Feature #5571 / File Upload: save filesize and mimetype automatically in 'upload mode simple',if those columns exist.
parent 2cfc2b4c
......@@ -3428,12 +3428,21 @@ See also `downloadButton`_ to offer a download of an uploaded file.
* *sqlBefore*, *sqlAfter*: available in :ref:`Upload simple mode` and :ref:`Upload advanced mode`.
* *slaveId*, *sqlInsert*, *sqlUpdate*, *sqlDelete*, *sqlUpdate*: available only in :ref:`Upload advanced mode`.
* To save the `fileSize` and / or `mimeType` (upload simple mode) in the same record as the upload: ::
* `fileSize` / `mimeType`
* In :ref:`Upload simple mode` the information of `fileSize` and `mimeType` will be automatically updated on the current
record, if table columns `fileSize` and/or `mimeType` exist.
* If there are more than one Upload FormElement in a form, the automatically update for `fileSize` and/or `mimeType`
can't be used.
* In :ref:`Upload advanced mode` the `fileSize` and / or `mimeType` have to be updated with an explicit SQL statement::
sqlAfter = {{UPDATE Data SET mimeType='{{mimeType:V}}', fileSize={{fileSize:V}} WHERE id={{id:R}} }}
* *fileReplace=always*: If `fileDestination` exist - replace it by the new one.
.. _`downloadButton`:
* *downloadButton*: If given, shows a button to download the previous uploaded file - instead of the string given in
......@@ -5127,9 +5136,9 @@ Special column names
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| _htmlentities |Characters will be encoded to their HTML entity representation. |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| _mimetype |Show mime type of a given file |
| _fileSize |Show file size of a given file |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| _filesize |Show file size of a given file |
| _mimeType |Show mime type of a given file |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| _thumbnail |Create thumbnails on the fly. See `column-thumbnail`_. |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
......@@ -5162,7 +5171,7 @@ Column: _link
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Render |r:<mode> |r:3 |See: `render-mode`_, Default: 0 |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Button |b[:0|1|<btn class>] | b:0, b:1, b:success |'b', 'b:1': a bootstrap button is created. 'b:0' disable the button. <btn class>: default, primary, success, info, warning,danger |
| | |Button | b[:0|1|<btn class>] | b:0, b:1, b:success |'b', 'b:1': a bootstrap button is created. 'b:0' disable the button. <btn class>: default, primary, success, info, warning,danger |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| |x |Picture |P:<filename> |P:bullet-red.gif |Picture '<img src="bullet-red.gif"alt="....">'. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
......
......@@ -1245,8 +1245,8 @@ const COLUMN_NL2BR = 'nl2br';
const COLUMN_HTMLENTITIES = 'htmlentities';
const COLUMN_STRIPTAGS = 'striptags';
const COLUMN_MIME_TYPE = 'mimetype';
const COLUMN_FILE_SIZE = 'filesize';
const COLUMN_MIME_TYPE = 'mimeType'; // Will also be used to identify equal named columns in upload record.
const COLUMN_FILE_SIZE = 'fileSize'; // Will also be used to identify equal named columns in upload record.
const COLUMN_WRAP_TOKEN = '+';
......
......@@ -344,6 +344,14 @@ class Save {
// 'Simple Upload': no special action needed, just process the current (maybe modified) value.
if ($pathFileName !== false) {
$newValues[$column] = $pathFileName;
if (isset($primaryRecord[COLUMN_FILE_SIZE])) {
$newValues[COLUMN_FILE_SIZE] = $vars[VAR_FILE_SIZE];
}
if (isset($primaryRecord[COLUMN_MIME_TYPE])) {
$newValues[COLUMN_MIME_TYPE] = $vars[VAR_FILE_MIME_TYPE];
}
}
} else {
// 'Advanced Upload'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment