Beispiel #1
0
 private function openTempFileHandler()
 {
     global $sessionObj;
     // try memory first
     if (($this->tempFileHandler = fopen("php://memory", 'r+')) === false) {
         // unable to use memory as temporary storage location,
         // try to create file in the session temp path
         if (empty($sessionObj)) {
             //session hasn't been initialized so far
             $sessionObj = new cmsSession();
         }
         $sessionTempPath = $sessionObj->getTempPath();
         $pathInfo = pathinfo($this->file);
         $tempFile = $sessionTempPath . '/' . $pathInfo['basename'];
         $idx = 1;
         while (file_exists($tempFile)) {
             $tempFile = $sessionTempPath . '/' . $pathInfo['filename'] . $idx++ . $pathInfo['extension'];
         }
         if (($this->tempFileHandler = fopen($tempFile, 'r+')) === false) {
             return false;
         }
         // remember tempFile, we will have to delete it after it fullfilled its purpose
         $this->tempFile = $tempFile;
     }
     return true;
 }