By ultimike on
Hello,
I'm about to start writing a module that reads and parses in XML data from an uploaded file, then saves certain data from the XML file into a DB table.
I have all the pieces I need except for how I'm going to interact with the upload module when the node is created and the file is uploaded. Are there any hooks that I can use to access the uploaded file or is it best to use hook_insert, look up the filename, and open it from there?
What is the best way to go about this?
Thanks,
-mike
Comments
This should get you started with uploading a file
I recently wrote a module that upload a CSV file and wrote the data to several tables. The following snippet is based on that code and shows the three functions I used to do this; example_import (displays the form), example_import_validate (makes sure the file is valid and if so saves the fileinfo) and example_import_submit (opens the file and processes it - incomplete in the example.
what about the upload module
Nevets,
Thanks for the quick response - your code looks good, but I'm hoping to use the upload module and all of its ajaxy goodness. Is this not possible?
Once a file is uploaded using the upload module and the node is saved, is the filename accessible via the $node array ($node->filename???). If so, then I can access it that way and do my processing then. Make sense?
Thanks,
-mike