Title: require(&#039;fpdf/fpdf.php&#039;) not working in wordpress plugin?
Last modified: August 30, 2016

---

# require('fpdf/fpdf.php') not working in wordpress plugin?

 *  [admiralchip](https://wordpress.org/support/users/admiralchip/)
 * (@admiralchip)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/)
 * Hello,
 * I have the FPDF library in a folder called fpdf and that folder is in my custom
   plugin folder. The problem is, whenever I try to use `require('fpdf/fpdf.php');`
   to make use of it, I end up getting an error that no such file or directory exists.
   I really want to get it to work.
 * Any idea why that’s happening?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288264)
 * The request is most likely looking for the folder in relation to a differnt folder,
   so it’s not finding it. The best way to make sure that it’s going to work is 
   to use the full file path. Something like this:
 * `$file_uri = plugins_url( 'fpdf/fpdf.php', __FILE__ );`
 * That will ensure that you always get the correct URI for the file, and you can`
   echo` it out to see if it really is correct (I always like to add in some de-
   bugging in situations like this).
 *  Thread Starter [admiralchip](https://wordpress.org/support/users/admiralchip/)
 * (@admiralchip)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288307)
 * Thanks for your reply!
 * I’ve tried what you suggested and I echoed it. The path is correct however it
   still says that the file cannot be found.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288378)
 * Then the file isn’t where you think it is. If it was, the script would find it.:/
 *  [Dion](https://wordpress.org/support/users/diondesigns/)
 * (@diondesigns)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288384)
 * The plugins_url() function returns a URL. The PHP allow_url_include setting is
   usually disabled for security reasons. When the setting is disabled, attempting
   to use include() or require() on an HTTP stream will fail.
 * If the fpdf.php file is located in the /fpdf subdirectory of the plugin, placing
   the following line as the first line of code in the plugin:
 *     ```
       define('MYPLUGIN_BASE_DIR', dirname(__FILE__));
       ```
   
 * and using the following line to load the file:
 *     ```
       require(MYPLUGIN_BASE_DIR . '/fpdf/fpdf.php');
       ```
   
 * will work. You can change MYPLUGIN_BASE_DIR to whatever you want.
 *  Thread Starter [admiralchip](https://wordpress.org/support/users/admiralchip/)
 * (@admiralchip)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288405)
 * Thanks for the code! I’ll try it as soon as possible and give feedback.
 *  Thread Starter [admiralchip](https://wordpress.org/support/users/admiralchip/)
 * (@admiralchip)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288406)
 * Nope, I tried it. It still doesn’t work. 🙁

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘require('fpdf/fpdf.php') not working in wordpress plugin?’ is closed 
to new replies.

## Tags

 * [folder](https://wordpress.org/support/topic-tag/folder/)
 * [fpdf](https://wordpress.org/support/topic-tag/fpdf/)
 * [require()](https://wordpress.org/support/topic-tag/require/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 3 participants
 * Last reply from: [admiralchip](https://wordpress.org/support/users/admiralchip/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/requirefpdffpdfphp-not-working-in-wordpress-plugin/#post-6288406)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
