• Resolved guylancaster

    (@guylancaster)


    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)

    (@sterndata)

    Volunteer Forum Moderator

    what is failing? the fopen? where are you executing this code?

    Thread Starter guylancaster

    (@guylancaster)

    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)

    (@sterndata)

    Volunteer Forum Moderator

    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.