variables - Restrict Upload on FileSize for FCKeditor PHP -


hi add restriction on uploading image files, on 500kb fck editor.

so in fck edior upload script there included require files:

require('./config.php') ; require('./util.php') ; require('./io.php') ; require('./commands.php') ; require('./phpcompat.php') ; 

filesize calcualted in commands.php file , thought take variable (from within function (commands.php) , test see if breaks limit size)

so still in upload.php, have snippet underneath require includes:

$limit_size = 512000;  if ( $globals['myfilesize'] >= $limit_size ) {      senduploadresults( 1, '', '', ''. $globals['myfilesize'].'' ) ; } 

so here function within commands.php file:

function getfoldersandfiles( $resourcetype, $currentfolder ) {     global $ifilesize;     // map virtual path local server path.     $sserverdir = servermapfolder( $resourcetype, $currentfolder, 'getfoldersandfiles' ) ;      // arrays hold folders , files names.     $afolders   = array() ;     $afiles     = array() ;      $ocurrentfolder = @opendir( $sserverdir ) ;      if ($ocurrentfolder !== false)     {         while ( $sfile = readdir( $ocurrentfolder ) )         {             if ( $sfile != '.' && $sfile != '..' )             {                 if ( is_dir( $sserverdir . $sfile ) )                     $afolders[] = '<folder name="' . converttoxmlattribute( $sfile ) . '" />' ;                 else                 {                     $ifilesize = @filesize( $sserverdir . $sfile ) ;                     if ( !$ifilesize ) {                         $ifilesize = 0 ;                         $globals['myfilesize'] = $ifilesize;                     }                     if ( $ifilesize > 0 )                     {                         $ifilesize = round( $ifilesize / 1024 ) ;                         if ( $ifilesize < 1 )                             $ifilesize = 1 ;                          global $myfilesize;                         $globals['myfilesize'] = $ifilesize;                     }                      $afiles[] = '<file name="' . converttoxmlattribute( $sfile ) . '" size="' . $ifilesize . '" />' ;                 }             }         }         closedir( $ocurrentfolder ) ;     }      // send folders     natcasesort( $afolders ) ;     echo '<folders>' ;      foreach ( $afolders $sfolder )         echo $sfolder ;      echo '</folders>' ;      // send files     natcasesort( $afiles ) ;     echo '<files>' ;      foreach ( $afiles $sfiles )         echo $sfiles ;      echo '</files>' ; } 

i approaching right? i'm thinking grab filesize value (i've messed trying make global variable?? ($globals[myfilesize]) , use in if statement see if filesize > limit_size???

thanks


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -