Possible Duplicate:
How can you upload an image from within a settings page?

I am developing a plugin. Which has a form.

The form contains the following fields.

  1. Course Name
  2. Course file.

The course file field is of type file from where I will upload a file. The name of the file I will store in database and the the uploaded file should save in the wp-content/uploads directory.

How will I do this in wordpress. I am new to plugin development so please help me out.


1 Answer 1


Have you looked at wp_upload_bits, it will create th file in the upload folder.

Example :

 $upload = wp_upload_bits( $_FILES["course_file"]["name"], null, file_get_contents( $_FILES["course_file"]["tmp_name"] ) );

Not the answer you're looking for? Browse other questions tagged or ask your own question.