WordPress.org

Ready to get started?Download WordPress

Forums

wp_handle_upload in functions.php file (4 posts)

  1. andriuss
    Member
    Posted 2 years ago #

    Hello,

    I have serious problem. When I want to load function wp_handle_upload in my theme functions.php file. It shows me error: Fatal error: Call to undefined function wp_handle_upload() in C:\xampp\htdocs\thisblog\wp-content\themes\geektheme\functions.php on line 150

    Why I get it in my theme ? Maybe I need to add any global word ?

    Thank you.

  2. andriuss
    Member
    Posted 2 years ago #

    Can anybody tell me?

  3. alesub
    Member
    Posted 2 years ago #

    Hi,

    It's because the function is meant to be used on a plugin, not a theme.

    Try including those files before the call:

    include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/media.php');
    include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/file.php');
    include_once($_SERVER['DOCUMENT_ROOT'].'wp-admin/includes/image.php');
  4. viniciusmassuchetto
    Member
    Posted 1 year ago #

    Better this way:

    include_once ABSPATH . 'wp-admin/includes/media.php';
    include_once ABSPATH . 'wp-admin/includes/file.php';
    include_once ABSPATH . 'wp-admin/includes/image.php';

Topic Closed

This topic has been closed to new replies.

About this Topic