Migration
From 2.1.x to 2.2.x
Cache folder
With version 2.2.0 the AjaxUpload cache folder has been moved into the MODX core
folder. The location is set with the new system setting ajaxupload.cache_path:
| Version | Cache folder |
|---|---|
| 2.1.x | assets/components/ajaxupload/cache/ |
| 2.2.x | {core_path}cache/ajaxupload/ by default |
During the update:
- The system setting
ajaxupload.cache_pathis created with the default value{core_path}cache/ajaxupload/. - The old cache folder
assets/components/ajaxupload/cache/is removed. It only contains temporary uploads. Uploads, that are not submitted with a form at the time of the update, are lost and have to be uploaded again. - If you have already set
ajaxupload.cache_pathto the old cache folder, the folder is not removed.
After the update:
- Make sure that PHP can write in the new cache folder. Otherwise the upload area shows the message Could not create the cache folder!.
- Make sure that the new cache folder is not accessible by the web server. See The cache folder for the recommended setup, the protection rules for Apache and nginx and how to check the protection.
- If the MODX core folder is located in the webroot and you use nginx, you need
a rule for the core folder. The rule for
/assets/components/ajaxupload/cachefrom the previous documentation can be removed.
Custom chunks
If you use your own copies of the tplAjaxuploadScript or
tplAjaxuploadUploadSection chunks (in the scriptTpl or uploadSectionTpl
properties of the AjaxUpload snippet), start again from the new default chunks
and re-apply your changes. Otherwise make these changes by hand:
tplAjaxuploadScript
- The
fetchURL has to end with&action=fetch&url=and theloadURL with&action=load&ref=. Otherwise adding files by URL and loading pre-filled files does not work. - The
process,patchandfetchendpoints are objects with anonerrorhandler, andlabelFileProcessingErrorandlabelFileLoadErrorare functions. They show the reason (File of invalid type or File is too large), when the server rejects a file. - The FilePond labels are passed as one
[[+labels]]object, so labels with apostrophes don't break the script. maxFilesis not passed to FilePond anymore. ThebeforeAddFile,onwarningandonremovefilecallbacks add the files that fit and show a message for the others.- A submit handler on the form blocks the submission, while files are uploading.
tplAjaxuploadUploadSection
- The element
<div id="filepond-warning-[[+uid]]" class="filepond-warning" role="alert" hidden></div>shows the messages of the script. - The
[[!+fi.error.[[+uid]]]]placeholder is wrapped in afilepond-warningbox, so the errors of the FormIt hooks are shown in red.
Old custom chunks keep working for normal uploads, but without these improvements.
Changed behaviour
- ajaxuploadAllowOverwrite disabled: If a file with the same filename exists in the target folder, the form shows an error and the upload queue is kept. Before, the uploaded file was silently dropped. See Set and retrieve the upload queue.
- Failed saves: If a file can't be saved or an upload has expired, the form shows an error and the upload queue is kept. See When saving fails.
- Order of the hooks: The AjaxUpload2Formit hook has to be the first
AjaxUpload hook in the
hooksproperty of the FormIt call. The other AjaxUpload hooks log an error, if they run before it. See Order of the hooks. - Denied file extensions: A built-in list of denied file extensions is
always used. The
deniedExtensionsproperty and theajaxupload.denied_extensionssystem setting add extensions to it. See Denied file extensions.
From 1.x to 2.x
With version 2.x the javascript handling of the file upload has been changed from Valums-File-Uploader/file-uploader to pqina/filepond. Because of this change, some snippet/hook properties are no longer needed and some snippet/hook properties are added. Some system settings have also been changed.
AjaxUpload snippet properties
The following snippet properties have to be removed or modified in the AjaxUpload snippet call:
| Old property | Change |
|---|---|
| addJquery | Remove from snippet call. |
| allowedExtensions | The property has to be replaced with the acceptedFileTypes property. The property value has to be modified. |
| language | Remove from snippet call. |
| maxFilesizeMb | The property has to be replaced with the maxFileSize property. The property value has to be modified. |
| thumbX | Remove from snippet call. |
| thumbY | Remove from snippet call. |
| uid | The uid should contain only alphanumeric characters. |
The following new properties are available and have to be added in the AjaxUpload snippet call:
| New property | Change |
|---|---|
| acceptedFileTypes | The property has to be replaced from the allowedExtensions property. The property value has to be modified. |
| fieldformat | The property has to be filled with the value of the ajaxuploadFieldformat property used in the according FormIt snippet call. |
| maxFileSize | The property has to be replaced from the maxFilesizeMb property. The property value has to be modified. |
| placeholderPrefix | The property has to be filled with the value of the placeholderPrefix property used in the according FormIt snippet call. |
| scriptTpl | The property has to be added to the snippet call, if you don't want to use the default. |
| showCredits | The property has to be added to the snippet call, if you don't want to use the default. |
| targetMediasource | The property has to be filled with the value of the ajaxuploadTargetMediasource property used in the according FormIt snippet call. |
| value | The property has to be added to the snippet call, if you don't want to use the default. |
FormIt hook properties
The following FormIt hook properties have to be removed or modified in the FormIt snippet call:
| Old property | Change |
|---|---|
| ajaxuploadClearQueue | Remove from snippet call. |
| ajaxuploadFieldname | Remove from snippet call. |
The following new properties are available and have to be added or modified in the FormIt snippet call:
| New property | Change |
|---|---|
| ajaxuploadCacheExpires | The property has to be added to the snippet call, if you don't want to use the default. |
| ajaxuploadSanitizeFilename | The property has to be added to the snippet call, if you don't want to use the default. |
| ajaxuploadTargetMediasource | The property has to be added to the snippet call, if you don't want to use the default. |
System settings
The following system settings are removed and not used anymore:
| Old Setting | Change |
|---|---|
| ajaxupload.image_tpl | Removed |