0

All, I'm using the Uploadify plugin to upload some images. I've included the uploadify folder in my themes folder. However, when I try and call uploadify.php I get the following error:

Call to undefined function wp_upload_dir()

My code looks like this:

global $cssPath, $jsPath, $themePath, $theLayout;
$upload_dir = wp_upload_dir();
echo $upload_dir['path'];

Any idea how I can use this properly? Thanks for any suggestions in advance!

1 Answer 1

2

It seems that you're either calling wp_upload_dir too early, when it has not yet been included in the scope (which is nearly impossible), or calling it without WordPress being even loaded (highly probable).

If you're using some sort of iframe to provide uploadify.php directly then WordPress will not be available for it. Include wp-load.php to load up a WordPress environment before actually trying to use wp_upload_dir. Alternatively, and much better, include uploadify.php into the WordPress scope instead in your template or hook, whatever you are using to position to the upload form correctly.

Better yet, just use the code inside from the basic demo inside your template file directly without the need for a separate uploadify.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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