Title: loading a file in php /wordpress
Last modified: September 1, 2016

---

# loading a file in php /wordpress

 *  Resolved [guylancaster](https://wordpress.org/support/users/guylancaster/)
 * (@guylancaster)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/loading-a-file-in-php-wordpress/)
 * Loading a flat file usually works on my dev WordPress and doesn’t work right 
   now on my live build – not good !
 * Here is my code. Can anyone suggest a bullet-proof version, please?
    Permissions
   have been set to 755 so its not that.
 *     ```
       if (is_admin()) $fl =  "../wp-content/plugins/carers/data/m.csv" ;
       else $fl  =  "wp-content/plugins/carers/data/m.csv" ;
       $handle = fopen($fl,"r");
       $fileContents	= fread($handle, filesize($fl));
       fclose($handle);
       ```
   
 * Tried get_site_url() to build a url for the file … and a wp function that did
   a fopen and if that didn’t work a curl …

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 9 months ago](https://wordpress.org/support/topic/loading-a-file-in-php-wordpress/#post-7659946)
 * what is failing? the fopen? where are you executing this code?
 *  Thread Starter [guylancaster](https://wordpress.org/support/users/guylancaster/)
 * (@guylancaster)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/loading-a-file-in-php-wordpress/#post-7659958)
 * fopen not working…..
 * After a lot of gnashing of teeth, worked out that it was my testing with 1 letter
   postcodes and the live system being tested with 2 letter postcodes, and my lower
   case conversion being a bit skew-wiff on the second postcode letter.
 * Thanks anyway.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 9 months ago](https://wordpress.org/support/topic/loading-a-file-in-php-wordpress/#post-7659963)
 * Glad you figured it out! I’ve marked this as resolved.

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

The topic ‘loading a file in php /wordpress’ is closed to new replies.

## Tags

 * [file](https://wordpress.org/support/topic-tag/file/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [read](https://wordpress.org/support/topic-tag/read/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/loading-a-file-in-php-wordpress/#post-7659963)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
