title: Howto: Drupal File Upload Form
body: <p>I'm having difficulty figuring out how to write a module with a form that uploads files, in Drupal 6. Can anyone explain this, or point me to a good example/documentation discussing it?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is entirely what I am trying to do:</p>
  
  <ol>
  <li>User uploads a .csv</li>
  <li>Module reads the first line of the file to get fields</li>
  <li>User matches csv fields with db fields</li>
  <li>Each csv line is saved as a node (preview it first)</li>
  </ol>
  
  <p>So far, I can do 1, 2, and 4 successfully. But it's unclear exactly how the steps should interact with each other ($form_state['redirect']? how should that be used?), and what the best practices are. And for 3, should I save that as session data?</p>
  
  <p>How do I pass the file data between the various steps?</p>
  
  <p>I know that node_import exists, but it's never worked for me, and my bug requests go ignored.</p>
  
  <p><strong>2nd EDIT:</strong> I used this at the start and end of every page that needed to deal with the file:</p>
  
  <pre><code>$file = unserialize($_SESSION['file']);
  //alter $file object
  $_SESSION['file'] = serialize(file);
  </code></pre>
  
  <p>I'm not sure it it's best practices, but it's been working.</p>