Importer uploads to incorrect directory
|Reported by:||duck_||Owned by:|
In some situations the importer may upload a file to a different directory compared to the export site.
Steps to reproduce:
- Ensure the default yyyy/mm uploads organisation setting is enabled.
- Create a post. Set the publish date to 2005/03/xx.
- Upload an image to the post, it will be uploaded to wp-content/uploads/2005/03/image.jpg per media_handle_upload(), see 
- Import on a new site.
The image will be located in wp-content/uploads/2011/03/ (subject to change, it will be the post_date of the attachment, i.e. date of upload).
This occurs because the attachment's post_date, which the importer relies on to set the upload directory, may be different to the folder it is stored in (see media_handle_upload() and  again).
Proposed solution is to attempt to grab the upload location from _wp_attached_file post meta and fallback to post_date which is correct in most cases.
Do we also want to start setting the post_date of attachments to be the same as the parent post? 'post_date' => $time in media_handle_upload() and friends.