Skip to content
  1. Extras
  2. FileAttach


Package to upload and attach files to resources in site manager.

  • Supports upload and download limitation by policies;
  • Has admin managing tool to control all uploaded files;
  • There is a media source for viewing uploaded files. It becomes available while package is globally registered during installation;
  • File list is kept in table

For every file could be set description, privacy mode (accessibility by direct link), download count, SHA1 checksum.

Files are accessible to download by direct link. For "private" files long name is randomly generated, that is not matched to original filename. For "open" files original filename is preserved.

Custom order may be set by enabling order column in editor and dragging selected rows to corresponding position.

Supports MySQL and SQLSrv DB schemes.

Component development is here:

Chunk FileAttachTpl

Allows to customize view of file item output.

&docidResource ID, where file uploaded
&downloadDownload count
&hashSHA1 checksum
&idFile ID
&internal_nameInternal name. File name in file system
&nameFile name. When private=false internal_name equal to name
&pathPath in media source
&privatePrivacy flag
&rankOrder in file list. May be used for custom sorting
&sizeFile size in bytes

Initial chunk content:

<a href="[[+url]]">[[+name]]</a> <span class="badge">[[+download]]</span>
[[+size:notempty=`<br/><small>Size: [[+size]] bytes</small>`]]
[[+hash:notempty=`<br/><small>SHA1: [[+hash]]</small>`]]</p>

Snippet FileAttach

Outputs file list.

NameDefault valueDescription
&limit0The number of files to limit per page. Show all items if not set
&makeURLfalseGenerate URL for file download
&outputSeparatorA string to separate each row with.
&privateUrlfalseForce private url. Allows to count downloads even with open files
&resource0Show files for resource id
&showSizefalseRetrieve file size
&sortBynameThe field to sort by.
&sortDirASCThe direction to sort by.
&toPlaceholderfalseIf set, will output the content to the placeholder specified in this property, rather than outputting the content directly.
&tplFileAttachTplThe chunk to use for each row of files.

Class FileItem


generateNameGenerate new filenamelength (int) = 32
getFullPathGet full file path
getPathGet file path relatively to media source root
getSizeGet file size
getUrlGet file link
renameRename filename (str)
sanitizeNameFilter unacceptable symbol combination in file namename (str)
setPrivateSet privacy modeprivate (bool)

System options

NameDefault valueDescription
calchashfalseCalculate file hash at upload
files_pathPath relative to media source root. Ends with "/"
mediasource1Media source ID
privatefalseMake file private at upload
put_docidfalseUpload file in subfolder with resource ID
templatesList of templates to activate module
user_foldersfalseUpload file in user ID subfolder

Connector for file download

Private file are downloaded through connector, what allows to hide direct link and and count downloads. It's available to download opened files through connector by calling snippet with &privateUrl=1, in this case connector will redirect to direct link.

Connector link looks like: MODX_ASSETS_URL/components/fileattach/connector.php?action=web/download&ctx=web&id=file_id, where file_id - sequential file ID in DB table.

Access policies

Permissions list

fileattach.doclistManage files in resource
fileattach.downloadPermission to download files
fileattach.totallistManage all files

Usage example

In simple case just call snippet:


To force download count it's needed to open files through private link:

[[FileAttach? &privateUrl=`1`]]

Custom sorting:

[[FileAttach? &sortby=`rank`]]


  • File list in manager

    File list in manager

  • Media source tree

Media source tree

  • File editor File editor

  • Editor in admin mode Editor in admin mode

  • File list in frontend File list in frontend

  • Upload dialog window Upload dialog window