[ic] Testing if file is Directory or File within content section of page?

Tim Good tim.g at edsd.com
Mon Aug 8 14:49:03 EDT 2005


Hello,

I was wondering if there is a way to do a test on a file
to see if it is a directory or a file within a page. I 
have the folling code but it returns error because of safe
mode:

my $path="images/items/".$event."/*";
@imgfiles = $Tag->list_glob("$path");

if ($#imgfiles < 0)
{
return "Image files do not exist for $event, please upload
images first!<br>";
}
else
{
     my $db = $Db{products} or return;
     my $sql = qq|insert into userdb
(username,password,event,event_id,event_name)
values('$event','$event',1,'$event','$event')|;
     my $results = $db->query( { sql => $sql } );
     $sql = qq|select max(cast(sku as signed)) from
products|;
     $results = $db->query( { sql => $sql, wantarray => 1 }
); 
     $skunum = $results->[0]->[0];
   for ($i=0; $i<=$#imgfiles; $i++){
     if ( -d $imgfiles[$i]) { 
        @imgfilessub = $Tag->list_glob($imgfiles[$i]."/*");
        for ($j=0; $j<=$#imgfilessub; $j++){
        ++$skunum;
        $imgfilessub[$j] =~ s|images/items/||;
          if ( $imgfilessub[$j] =~ m/(\d\d\d).jpg$/) {
            $imgnum = $1;
          }
        $itemdesc = $event."_color_4x6_".$imgnum; 
        $sql = qq|insert into products (sku,description,
thumb,image,price,prod_group,category,option_type,image_larg
e,type_id) values
('$skunum','$itemdesc','$imgfilessub[$j]','$imgfilessub[$j]'
,'8.00','customer','$event','TypeSimple','$imgfilessub[$j]',
'photo')|;
        $results =$db->query( { sql => $sql } );
      }
     else {
        @imgfiles = $Tag->list_glob($imgfiles[$i]."/*");
        ++$skunum;
        $imgfiles[$i] =~ s|images/items/||;
          if ( $imgfiles[$i] =~ m/(\d\d\d).jpg$/) {
            $imgnum = $1;
          }
        $itemdesc = $event."_color_4x6_".$imgnum; 
        $sql = qq|insert into products (sku,description,
thumb,image,price,prod_group,category,option_type,image_larg
e,type_id) values
('$skunum','$itemdesc','$imgfiles[$i]','$imgfiles[$i]','8.00
','customer','$event','TypeSimple','$imgfiles[$i]','photo')|
;
        $results =$db->query( { sql => $sql } );
      }
     }
     }
   return;
}

Tim Good
EDSD, LLC
tim.g at edsd.com
406.829.1200 




More information about the interchange-users mailing list