title: call media_sideload_image in new directory
body: <p>I am trying to call media_sideload_image as part of an import from an XML feed but i havent had much luck at all - it is currently in a directory (localhost/wordpressdirectory/wordpress/wp-admin/imports) but i keep getting a no such directory error when it tries to contact any of the required files.</p>
  
  <p>See code below which is basically copied from the WP guide for media_sideload_image:    </p>
  
  <pre><code>&lt;?php 
  define('ABSPATH', dirname(__FILE__));
  
  echo ABSPATH . '\wp-admin\includes\plugin.php';
  require_once( ABSPATH . '\wp-admin\includes\plugin.php');
  require_once( ABSPATH . '\wp-admin\includes\media.php');
  require_once( ABSPATH . '\wp-admin\includes\file.php');
  require_once( ABSPATH . '\wp-admin\includes\image.php');
  
  $url = "http://s.wordpress.org/style/images/wp3-logo.png";
  $post_id = 1;
  $desc = "The WordPress Logo";
  
  $image = media_sideload_image($url, $post_id, $desc);
  ?&gt;
  </code></pre>
  
  <p>I have echoed this and it comes up with this which is not a valid file path:
  C:\wamp\www\wordpressdirectory\wordpress\wp-admin\imports\wp-admin\includes\plugin.php</p>
  
  <p>How can i fix this in localhost ideally without hard referencing any requirements to their physical location since abspath seems to be returning an incorrect value?</p>