http://codex.wordpress.org/Function_Reference/image_downsize
Returns:
(bool|array) False on failure, array on success. Array with image url, width, height, and whether is intermediate size, in
that order is returned on success is returned. $is_intermediate is
true if $url is a resized image, false if it is the original.
I am going to assume the array within the array part is completely odd.
So let’s start working backwards…
http://codex.wordpress.org/Function_Reference/wp_insert_attachment
Returns an array of key => value pairs containing path information on
the currently configured uploads directory.
Example:
$upload_dir = wp_upload_dir();
echo $upload_dir['baseurl'];
I see that you have this instead:
$wpUploadPath = wp_upload_dir(); // this returns an array!
$target_path = $wpUploadPath; // now the target_path is an array?
That is setting the target path to an array instead of a string…
Also – target_path shouldn’t be a full path..it should be the file name.
The whole purpose of wp_upload_dir() is to determine the path.
The usage of wp_insert_attachement is as follows:
wp_insert_attachment( $attachment, $filename, $parent_post_id )
Notice how it says $filename.
Since you are passing $target_path as the second parameter into wp_insert_attachement() and that second parameter is intended to represent the filename, it makes the most sense that this is your problem.