views:

104

answers:

1

Hi,

I have a form which uploads multiple file fields into a db using codeigniter.

I need to be able to upload multiple files for each field. I understand that this could be achieved using some jquery magic, however, my problem is how do I intercept the multiple files and what is the best way to store them in my database?

At the minute I just have one field which stores the file location/name, would I need to insert all the files as one long comma seperated string? If so, how do I then make use of that string for my view functions to show each file?

Sorry if the above doesn't make sense, I can explain in more detail or post my code if required.

Thanks for any help in advance

Dan

+1  A: 

It pains me to say this, but the best method of uploading multiple files at once is to use a plugin like Uploadify.

With regard to how you'd like to store it in the database...If you're allowing a single user to upload multiple files, I'd recommend having three tables:

  1. Users (user_id, username, email, etc.)
  2. Files (file_id, filepath, time_uploaded, etc.)
  3. Users_files (user_id, file_id)

Then when you store the files on your server, you can insert a new row into your "files" table. Then when you delete files, be sure to remove the row in the files table and the association in the users_files table.

treeface