• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
image uploading..

#1
[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 ?

#2
[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:


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.