Gdn_Upload::canUpload PHP Method

canUpload() public static method

public static canUpload ( null $UploadPath = null ) : boolean
$UploadPath null
return boolean
    public static function canUpload($UploadPath = null)
    {
        if (is_null($UploadPath)) {
            $UploadPath = PATH_UPLOADS;
        }
        if (ini_get('file_uploads') != 1) {
            return false;
        }
        if (!is_dir($UploadPath)) {
            @mkdir($UploadPath);
        }
        if (!is_dir($UploadPath)) {
            return false;
        }
        if (!isWritable($UploadPath) || !is_readable($UploadPath)) {
            return false;
        }
        return true;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Check that we have the necessary tools to allow image uploading.
  *
  * @return bool
  */
 public static function canUploadImages()
 {
     // Is the Uploads directory available and correctly permissioned?
     if (!Gdn_Upload::canUpload()) {
         return false;
     }
     // Do we have GD?
     if (!function_exists('gd_info')) {
         return false;
     }
     $GdInfo = gd_info();
     // Do we have a good version of GD?
     $GdVersion = preg_replace('/[a-z ()]+/i', '', $GdInfo['GD Version']);
     if ($GdVersion < 2) {
         return false;
     }
     return true;
 }
All Usage Examples Of Gdn_Upload::canUpload