[wp-hackers] Allow users to upload their own images - hook to use?

Gregory Lancaster greglancaster71 at gmail.com
Thu Sep 12 19:18:27 UTC 2013


oh my god. thank you j.d.  I am [obviously] still learning PHP and I was
under the impression I was required to have the $_POST[] form handler.  I
literally spend hours fumble fuc**** around with this.  Well I feel like a
complete idiot.  Thank you so much for your help.


On Thu, Sep 12, 2013 at 12:14 PM, J.D. Grimes <jdg at codesymphony.co> wrote:

>
> 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 *****/
> > ));
> >       }
> >   }
> > }
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list