• Resolved jaspercreel

    (@jaspercreel)


    Hi there! Love the plugin, but I’m having a little hangup. I am trying to use a scandir() function and it’s giving me an error. Here’s my code:

    $dir = “../wp-content/uploads/easter_pics”;
    $images = scandir($dir);

    And the error is:

    Warning: scandir(../wp-content/uploads/easter_pics): failed to open dir: No such file or directory in /home/jaspercreel87/public_html/jaellebrain.com/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 4

    Warning: scandir(): (errno 2): No such file or directory in /home/jaspercreel87/public_html/jaellebrain.com/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 4

    Is it not possible to escape the plugin folder to follow another path using scandir()?

    https://www.ads-software.com/plugins/insert-php/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    I’m uncertain which is the current working directory when the plugin is running.

    Try one dot instead of two at the beginning of the path.
    "./wp_content/uploads/easter_pics"

    If no joy, specify the path with document root.

    "{$_SERVER['DOCUMENT_ROOT']}/wp_content/uploads/easter_pics"

    Will

    Thread Starter jaspercreel

    (@jaspercreel)

    Using one dot worked! Thanks so much. I am new to PHP so not sure why that would make a difference but thanks for the help! Love the plugin, I’ll give it 5 stars.

    Thread Starter jaspercreel

    (@jaspercreel)

    Marking this resolved

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't use scandir() with this plugin’ is closed to new replies.