views:

75

answers:

2

I'm building an app which needs to take uploaded files and put them in separate directories for thumbnails and fullsize images. But $config['upload_path'] = './uploads/'; only allows me to select one upload path. How do I define two or more upload paths?

A: 

The short (and disappointing) answer is: CodeIgniter's file uploading class was designed to accept 1 uploaded file per form.

The long answer is somewhere around here.

kitsched
A: 

You're conflating two issues here. You need to further decompose the problem into discrete tasks.

First of all, you need to set the appropriate upload directory. On my site, each user is directed to their own upload directory:

/images/member/1
/images/member/2
/images/member/3

My controller sets the upload directory dynamically, based on user id

$config['upload_path'] = "/images/member/$user_id";

Second, you need to process your uploaded file, creating resized and thumbnail images. My image processing library uses the same path that I passed to $config['upload_path'] as its root directory, and places its output into subdirectories relative to that dynamic root:

/images/member/1/resized
/images/member/1/thumbnails

My site is actually a little more complex than that. But the point is that setting $config['upload_path'] dynamically lets you have as many upload paths as you want.

coolgeek
Very nice, thank you!
pigfox