[wp-hackers] Allow users to upload their own images - hook to use?
J.D. Grimes
jdg at codesymphony.co
Thu Sep 12 19:14:27 UTC 2013
On Sep 12, 2013, at 3:10 PM, Gregory Lancaster <greglancaster71 at gmail.com> wrote:
> I have no idea how I would insert that into $ _POST. It wont take it, says
> its an array. I tried it. Would you (JD) link me to a reference that
> would explain how $_POST can work with variables in this way?
You don't need to insert it into $_POST. Sorry IF I confused you into thinking that.
Example of how you might use it:
> ///SUBMIT FORM CODE
>
> $post_id = NULL;
> global $wpdb;
> if ($_FILES) {
> foreach ($_FILES as $key => $value) {
> $newupload = insert_attachment($file, $post_id);
> /****** $newupload returns the attachment id of the file that *****/
> // was just uploaded. Do whatever you want with that now.
>
>
> if (isset($_POST['submit'])) {
> $wpdb->insert(wp_jo_plugin_options, array (
> 'user_id' => $_POST['user_id'],
> 'length' => $_POST['length'],
> 'ground' => $_POST['ground'],
> 'date' => $_POST['date'],
> 'file' => $_FILES['file'],
> 'attach_id' => $newupload, /***** EDIT *****/
> ));
> }
> }
> }
More information about the wp-hackers
mailing list