title: wordpress image upload for custom post type
body: <p>I'm creating an image upload form for a custom post type but i don't know how to upload the image to the custom post type.  The custom post type is called 'art'.</p>
  
  <p>Here is my code.</p>
  
  <p>form html</p>
  
  <pre><code>&lt;form id="art_submission_form" enctype="multipart/form-data" method="post" action="art_process.php"&gt;
       &lt;div class="art_upload_container" &lt;?php echo $style; ?&gt;&gt;
              &lt;div class="art_sub_row"&gt;
              &lt;select class="art_sub_select" name="art_creation_date"&gt;
                  &lt;option value="Creation Date"&gt;Creation Date&lt;/option&gt;
              &lt;?
                  $dates = array("2014","2013","2012","2011","2010","2009","2008","2007","2006","2005","2004","2003","2002","2001","2000","1999",
                  "1998","1997","1996","1995","1994","1993","1992","1991","1990","1989","1988","1987");
  
                  foreach($dates as $value) {
                      echo "&lt;option value='$value'&gt;$value&lt;/option&gt;";
                  }
              ?&gt;
              &lt;/select&gt;
  
              &lt;div class="art_sub_col"&gt;&lt;label&gt;Art Title&lt;/label&gt;&lt;input type="text" class="art_title" name="art_title[]" value="&lt;?php echo $art_title; ?&gt;" /&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="art_sub_row"&gt;
              &lt;div class="art_sub_col"&gt;&lt;label&gt;Width(cm)&lt;/label&gt;&lt;input type="text" class="art_width" name="art_width[]" value="&lt;?php echo $art_width; ?&gt;" /&gt;&lt;/div&gt;
              &lt;div class="art_sub_col"&gt;&lt;label&gt;Height(cm)&lt;/label&gt;&lt;input type="text" class="art_height" name="art_height[]" value="&lt;?php echo $art_height; ?&gt;" /&gt;&lt;/div&gt;
              &lt;div class="art_sub_col"&gt;&lt;label&gt;Price&lt;/label&gt;&lt;input type="text" class="art_price" name="art_price[]" value="&lt;?php echo $art_price; ?&gt;" /&gt;&lt;/div&gt;
              &lt;/div&gt;
                  &lt;div class="art_sub_row"&gt;
              &lt;div class="art_sub_col"&gt;&lt;label&gt;Upload Art:&lt;/label&gt; &lt;input type="file" name="art_upload[]" class="art_upload"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;input type="submit" class="art_sub_send" value="Send" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>art_process.php - what i've done so far</p>
  
  <pre><code>  $art_title = $_POST['art_title'];
  
      $i = 0;
      foreach($art_title as $value) {
      $art_title = $_POST['art_title'][$i];
      $art_width = $_POST['art_width'][$i];
      $art_height = $_POST['art_height'][$i];
      $art_price = $_POST['art_price'][$i];
      $art_creation_date = $_POST['art_creation_date'][$i];
  
  
    // Add the content of the form to $post as an array
      $new_post = array(
          'post_title'    =&gt; $art_title,
          'post_status'   =&gt; 'draft',    
          'post_type' =&gt; 'art'
      );
      //save the new post
      $pid = wp_insert_post($new_post); 
  
  
      $i++;
      }
  </code></pre>
  
  <p>Is there a built in wordpress function to upload image to a custom post type?</p>