How do I let users upload files to a chosen location?

In PHP, instead of:

<form method="POST" action="url">

Use this instead:

<form enctype="multipart/form-data" method="post" action="url">

You can then fetch the resulting files using the $_FILES superglobal.


In WP 3.1, the whole uploads infrastructure should be available as an API unless I’m mistaking. But it won’t necessarily work on the front end, let alone allow you to easily decide where the files go.

You could use parts of it to validate file types, etc., though. See the stuff in:

  • wp-includes/media.php
  • wp-admin/includes/media.php