convert multipart form (input type = file) into WordPress media library upload


Staff member
I'm trying to modify a wordpress plugin and need to decide if it's feasible to tweak the changes I want, or not possible.

<h2>The bad feature I'm trying to fix:</h2>

This plugin uses customized posts. When a user creates a new post of this type, there is a button to upload an image. This upload relies on a multipart(input type = file) instead of the media library. I'm trying to intercept this process and stick in a media uploader... then pass the data to the next function as though it were coming from a non-wordpress multi-part form. Tons of functions after this point rely on the data coming in a certain way, which is why I'm trying to mimic the results of a naturally uploaded file.

<h2>Issues I'm stuck on:</h2>

<li>The function called after submit is waiting for $_FILES array data to come in. I'm not sure if it's possible to force my own data (returned from media uploader javascript) into this array</li>
<li>Even if I could force data into $_FILES, capturing the returned JavaScript values into PHP variables seems like a problem. - I was considering using 'on_submit' and makeing a JS function to populate an HTML input with values...but I can't think of how to easily get those values into the $_FILES afterwards. </li>
<li>The media Library does use $_FILES array (wordpress core includes/media.php) but those values are null by the time I var_dump in my plugin files.</li>