« Why I like using the Extended field | Main | How to Fix a Common MT4 Feed Formatting Error »

How To Change the Default Image Upload Location in Movable Type 4.0

Nearly every article for my site Correspondence Notes contains at least one image. I use Movable Type's built in upload feature to upload images and add them to entries. The process is fine except for one step. By default Movable Type will upload images to your Site Root. That's great except I like my images to go into a subdirectory I like to call...images. I can of course, with the file upload utility, tell Movable Type to put the images into the images subdirectory. The problem is that the utility will not remember this preference. Every time I upload an image I have to tell Movable Type again to put the new image in the images directory instead of the Site Root. Though it only takes a few key strokes to type "images" into the subdirectory field it's a silly time waster since I want every single image I upload to go into that folder.

Since there isn't an option within the Movable Type user interface to make the file upload utility remember that I want my images to always go into the images subdirectory I decided to go straight to the source and make it happen.

Please remember that if these steps break your copy of Movable Type I'm not the least bit responsible.

Configuring the upload utility to upload to the same subdirectory by default is actually quite simple. It only requires editing a single line of a single .tmpl file. However, if monkeying with an application's source code makes you really nervous I've heard there is a great plugin for improving Movable Type's file upload utility that only costs $10.

The file to edit is called asset_upload.tmpl. Assuming you have your Movable Type files in your cgi-bin the path to this file looks something like cgi-bin/mt/tmpl/cms/dialog/asset_upload.tmpl.

1. Download asset_upload.tmpl (I highly recommend you save a backup copy of it before you edit it)

2. Open asset_upload.tmpl and look for the following:
/ <input name="extra_path" id="extra_path" value="<mt:var name="extra_path" escape="html">" />

3. Change
value="<mt:var name="extra_path" escape="html">"
where "images" is whatever subdirectory name you want your images uploaded to by default.

So your final code should look like this

/ <input name="extra_path" id="extra_path" value="images" />

4. Save and upload asset_upload.tmpl

5. Upload an image


You'll notice that the subdirectory field is still completely editable. So while Movable Type will, by default, now upload my images to the images subdirectory, should I want to upload a particular image to a different directory all I have to do is type a different name into the subdirectory text box.

Comments (8)

Thanks Michelle for this useful hack. 6A really should let users save their preferred directory for file uploads. Until they fix this, and make it easier for us, your solution will come in handy.

Michael Wincott:

Thank you so much for this. I've lost count of how many times I've had to type 'images'!

Hi Michelle,

To be nitpicky, it seems like the text:

"<mt:var name="extra_path" escape="html">"

is there so that a user can set the variable called "extra_path" at the top of the file and it will do what you want it to do.

So, instead of deleting it and hardcoding "images" in place, you can instead insert the following line at the top of the file to accomplish the same thing in maybe a more "correct" way:

<mt:setvar name="extra_path" value="images">


This is great if you just want to set the path to be below the "Site Root" settings in MT. What if you wanted to break out of that though and publish in a higher level folder?

For example, let's say the site domain is foo.com and the blog is called apple and the site root is http://www.foo.com/apple/

Instead of publishing your images to http://www.foo.com/apple/images, you want it to publish in http://www.foo.com/images is that even remotely possible?

Thanks in advance, both for the tutorial and for any further clarification.

Mashby I can't think of anyway to do that off the top of my head. You might check out the Better File Uploader plugin, it very well may do what you're looking for.


In MT4.1, the file to edit is still called asset_upload.tmpl.

However, it's not in:

It's here instead:

It's in the "include" folder, not the "dialog" folder.

Right you are Brad. I meant to update this post with that information but you've laid it out in your comment. Thanks!

You still might want to update the post with the correct file location. I don't usually look at the comments when I'm following the directions in a post, and it took me several minutes to see Brad's post.

Thanks for the tip!

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)