By webchuck on
Drupalers,
I have a large number of files (in the thousands) which I need to add to Drupal. Obviously, I'm not going to do this by hand, so I am writing a script to do this. I have figured out how to create nodes for each document (node_save), but now need to figure out how to attach the files to the node. I looked over upload.module, but didn't understand it well enough to guess which function I needed to call.
Can anyone offer some ideas how I can do this?
Thanks!!!
Comments
I'd like to know too.
I'd like to know too.
Figured this out...
Cheeze,
Here's what I figured out. There's a function called upload_save($node) in upload.module. If you create a node, save it using node_save(), you can then pass that node into upload_save and it will correctly add the files to your db. Here's the snippet of code I used.
Disclaimer: I am not a PHP guru, nor a Drupal guru, so this may not be the best syntax. If you have suggestions for improvement, let me know.
----------------------------------------
Chuck Crandall
WebChuck Web Development
chuck at webchuckweb dot com
----------------------------------------