0

i get this error when i am making a list in the admin panel for the codes beneath i will send a screenshot of the error enter image description here i need to do the deleting operation apart from listing, im waiting for your help

function aksesuar_resim_deletes()

{

    $directory = get_home_path(). '/wp-content/aksesuar/';
    $files = glob($directory .'*');

    if ( ! isset( $_REQUEST['settings-updated'] ) ) $_REQUEST['settings-updated'] = false;


    ?>
    <div class="wrap">
        <?php screen_icon(); echo "<h2>". __( 'Resim Silme Servisi', 'aksesuar_resim_deletes' ) . "</h2>"; ?>
        <?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
            <p><strong><?php _e( 'Options saved', 'aksesuar_resim_deletes' ); ?></strong></p>
        <?php endif; ?>
        <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
            <?php settings_fields( 'aksesuar_resim_uploads' ); ?>
            <?php $options = get_option( 'aksesuar_resim_uploads' ); ?>
            <div id="wp-theme-file-uploader">
                <p>
                    <label for="folders">Resim Klasörü Seç:</label>
                    <select name="folder">
                        <?php foreach($files as $file): ?>
                            <?php if(is_dir($file)): ?>
                                <option value="<?php echo basename($file); ?>"><?php echo basename($file); ?></option>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </select>
                </p>
                <input class="button-primary" type="submit" name="submit" value="Resimleri getir">
            </div>
        </form>
    </div>

    <?php
    $imageFiles = array();
    $extensions = array('.JPG','.PNG','.JPEG');
    $dir =home_url().'/wp-content/aksesuar/'.$_POST['folder'];
    $openDir = opendir($dir);

    while ($imgFile = readdir($openDir))
    {
        if ($imgFile <> '.' and $imgFile <> '..')
        {
            $extension = strtoupper(substr($imgFile, strrpos($imgFile, '.')));
            if (in_array($extension, $extensions))
            {
                $imageFiles[] = $imgFile;
            }
        }
    }

    closedir($openDir);
    echo '<ul>';
    foreach ($imageFiles as $k => $v)
    {

        echo '<li style="float: left;padding-right: 10px;"><img src="'.$dir.'/'.$v.'" width="238" height="238" alt=""/></li>';

    }
    echo '</ul>';
}
1

opendir operates on directories on a filesystem, not HTTP URIs.

While some HTTP URIs return directory listings (the one you are using doesn't, it is a 404 error), those listings as HTML documents generated by the webserver and are not actual directories.

So please change value of $directory variable.

For Example:

Current value in $directory = "http:/localhost/WP/wp-content";

Need to be correct like : $directory ='<wwwroot>/WP/wp-content';

NOTE: [opendir()][1] is used to open a local directory and since PHP 5.0.0 on an ftp directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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