How to upload a file in Wordpress using a custom upload form?

I do not want to use Wordpress built into the media downloader.

I have a form (on the interface) of my site, and I need to allow someone to upload the image to my uploads folder in wp-content. I found many tutorials, but they all tell me how to do this with the wordpress loader. I need to be able to verify what users are downloading.

Any help is much appreciated !!!

Thanks.

+8
file-upload wordpress
source share
2 answers

solved. This is the code I used for this:

In my code:

require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $attachment_id = media_handle_upload('file-upload', $post->ID); 

In my form:

 <input type="file" name="file-upload" id="file-upload" /> 
+7
source share

Does it help?

WPTuts: Allow Users to Submit Images to Your Site

PHP:

 require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $attachment_id = media_handle_upload('file-upload', $post->ID); 

HTML:

 <input type="file" name="file-upload" id="file-upload" /> 
+22
source share

All Articles