I've been unsuccessful in tracking down any in depth resources on file handling in Drupal 5.x.
The module I'm working on has custom forms and I wish to allow users to attach an arbitrary number of files that will be saved to the server using Drupal's built in file handling along with the rest of the form data. I've read through the api.drupal.org information on File Interface functions, but can't seem to piece it all together. I also have the Pro Drupal Development book, but its chapter on "Working with Files" is all of 7 pages long and nearly useless from a developer standpoint.
Are there any good tutorials on how to go about file upload(s) in custom forms? Any resources would be welcome, though a nice walk through example would be ideal if one already exists.
Thanks!
Comments
subscribing
subscribing
www.chrisbovard.com | Drupal Developer / Themer
subscribing
subscribing
Probably about a year too late for you, but...
Here's how a bare bones version of the Drupal file upload API seems to work. You'll need something a lot more complicated if you want to use multipart forms, do lists of files, editing, etc, but this seems to work for a starter (developed by trial and error and inspection of a lot of stuff with Firebug - I couldn't find any documents either).
Step 1: include a file element in your form, such as:
Step 2: in your validation function, retrieve the file. You can now do stuff with it using the APIs to be found on http://api.drupal.org/api/group/file/5
Step 3: in your submit function, store the file away somewhere.
I hope this helps someone!
David
Thanks
Thanks, it's very useful example.
http://api.drupal.org/api/function/file_check_upload/5
In Drupal 6, this has been renamed to file_save_upload()
I can't find a drupal 7
I can't find a drupal 7 version for this that could work. Any help?