[Prev: ARCHIVE] | [Resources][TOC] | [Next: ATTACHMENTURL]

# ATTACHMENTDIR

- Syntax
- Description
- Default Setting
- Resource Variables
- Examples
- Version
- See Also

## Syntax

Envariable

  `M2H_ATTACHMENTDIR=`pathname

Element

  `<ATTACHMENTDIR>`
  pathname
  `</ATTACHMENTDIR>`

Command-line Option

  `-attachmentdir` pathname

## Description

ATTACHMENTDIR specifies the pathname directory location attachments will be saved. If ATTACHMENTDIR is a relative pathname, it will be relative to OUTDIR. For example, if OUTDIR is set to:

    /var/www/html/archive

And ATTACHMENTDIR is set to:

    attachments

Then attachment files will be saved to

    /var/www/html/archive/attachments

If ATTACHMENTDIR is not set, attachments will be saved in OUTDIR.

When defining ATTACHMENTDIR, the ATTACHMENTURL resource should also be set.

## Default Setting

Nil.

## Resource Variables

N/A

## Examples

By default, attachment files are written in the same directory as message and index pages. However, if you would like to have all attachments written in a sub-directory of the archive directory, you can do something like the following:

    <!-- Have attachments written to a sub-directory -->
    <AttachmentDir>
    attachments
    </AttachmentDir>

    <!-- Define base URL to attachment directory. -->
    <AttachmentURL>
    attachments
    </AttachmentURL>

Notice how ATTACHMENTURL is equal to ATTACHMENTDIR. When ATTACHMENTDIR is set to a relative pathname, ATTACHMENTURL should be set to the same value. This way, if archive files are moved to a different location on the file system, links to attachments will not break.

If maintaining multiple archives, and to provide for better security, you may want have all attachments for all archives written to a single location. The attachment location can then have more restrictive HTTP server and file system settings to provide further protection against malicious attachments.

The following example shows ATTACHMENTDIR being set to a central location and then defining ATTACHMENTURL so MHonArc knows what base URL to use when creating links to attachment files:

    <!-- Have all attachments written to central location -->
    <AttachmentDir>
    /var/www/html/archives/attachments
    </AttachmentDir>

    <!-- Define base URL to attachment directory. -->
    <AttachmentURL>
    /archives/attachments
    </AttachmentURL>

In this case, ATTACHMENTURL does not equal ATTACHMENTDIR since ATTACHMENTDIR is a full pathname. Therefore, ATTACHMENTURL must be set to a value tha HTTP server will resolve to the value of ATTACHMENTDIR.

NOTE: | In this example, we do not include the "`http://hostname`" part of the URL since attachment files will be served up from the same HTTP server as other archive pages.

## Version

2.6.9

## See Also

ATTACHMENTURL, OUTDIR

[Prev: ARCHIVE] | [Resources][TOC] | [Next: ATTACHMENTURL]