CodeIgniter Forums
image uploading.. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: image uploading.. (/thread-54428.html)



image uploading.. - El Forum - 09-07-2012

[eluser]Captain_Fluffy_Pants[/eluser]
so for the image uploading and send to a view i created this code for the view
Code:
<?php
$dirFiles = array();
// opens images folder
if ($handle = opendir('/home/lulzlab/public_html/uploads')) {
    while (false !== ($file = readdir($handle))) {

        // strips files extensions      
        $crap   = array(".jpg", ".jpeg", ".JPG", ".JPEG", ".png", ".PNG", ".gif", ".GIF", ".bmp", ".BMP", "_", "-");    

        $newstring = str_replace($crap, " ", $file );  

        //asort($file, SORT_NUMERIC); - doesnt work :(

        // hides folders, writes out ul of images and thumbnails from two folders

        if ($file != "." && $file != ".." && $file != "index.php" && $file != "Uploads") {
                $dirFiles[] = $file;
        }
    }
    closedir($handle);
}

sort($dirFiles);
foreach($dirFiles as $file)
{
    echo "<li><a ><img ></li>\n";
}

?&gt;
this is what it turned out to look like so it almost worked http://i.imgur.com/e5RHy.png can someone please help me :c ?


image uploading.. - El Forum - 09-07-2012

[eluser]Captain_Fluffy_Pants[/eluser]
nevermind i got it to work !
Code:
&lt;?php
$dirFiles = array();
// opens images folder
if ($handle = opendir('/home/lulzlab/public_html/uploads')) {
    while (false !== ($file = readdir($handle))) {

        // strips files extensions      
        $crap   = array(".jpg", ".jpeg", ".JPG", ".JPEG", ".png", ".PNG", ".gif", ".GIF", ".bmp", ".BMP", "_", "-");    

        $newstring = str_replace($crap, " ", $file );  

        //asort($file, SORT_NUMERIC); - doesnt work :(

        // hides folders, writes out ul of images and thumbnails from two folders

        if ($file != "." && $file != ".." && $file != "uploads" && $file != "uploads") {
                $dirFiles[] = $file;
        }
    }
    closedir($handle);
}

sort($dirFiles);
foreach($dirFiles as $file)
{
    echo "<li><a ><img ></li>\n";
}

?&gt;
c: