error("Could not read session"); return; } foreach ($_FILES as $field => $file) { if ($file['error'] == UPLOAD_ERR_OK) { if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) { $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_'); } else { $new_file = $value['file']['tmp_name'].'+'; } // Files come from ajax Base64 encoded $handle = fopen($new_file, 'w'); list($prefix, $data) = explode(',', file_get_contents($file['tmp_name'])); $file['tmp_name'] = $new_file; fwrite($handle, base64_decode($data)); fclose($handle); // Store info for future submit $data = egw_session::appsession($request_id.'_files'); $form_name = self::form_name($cname, $field); $data[$form_name][] = $file; egw_session::appsession($request_id.'_files','',$data); } } } /** * Validate input * Merge any already uploaded files into the content array * * @param string $cname current namespace * @param array $content * @param array &$validated=array() validated content */ public function validate($cname, array $content, &$validated=array()) { $form_name = self::form_name($cname, $this->id); $value = $value_in = self::get_array($content, $form_name); $valid =& self::get_array($validated, $form_name, true); $files = egw_session::appsession(self::$request->id().'_files'); $valid = $files[$form_name]; } } etemplate_widget::registerWidget('etemplate_widget_file', array('file'));