Ejemplo n.º 1
0
 public function insertFile()
 {
     if (isset($_FILES['file']['name'])) {
         $guid = mgGetGuid();
         $path = __UPLOAD__ . mgGetGuidPath($guid);
         if (!is_dir($path)) {
             mgMkdir($path);
         }
         move_uploaded_file($_FILES['file']['tmp_name'], $path . '/' . $guid);
         $fileModel = $this->loadModel('files');
         $fileModel->insertTable(array('file_name' => $_FILES['file']['name'], 'file_type' => $_FILES['file']['type'], 'file_guid' => $guid, 'file_size' => $_FILES['file']['size'], 'file_time' => time() - $this->stack['static_var']['server_timezone'], 'file_describe' => $_POST['file_describe']));
     }
     $this->result['open'] = true;
     $this->result['word'] = '您的文件 "' . $_FILES['file']['name'] . '" 已经提交成功';
 }
Ejemplo n.º 2
0
 public function mwNewMediaObject($args)
 {
     $blogId = intval($args[0]);
     $userName = $args[1];
     $password = $args[2];
     $data = $args[3];
     $guid = mgGetGuid();
     $data['name'] = basename($data['name']);
     $path = __UPLOAD__ . mgGetGuidPath($guid);
     if (!is_dir($path)) {
         mgMkdir($path);
     }
     $success = file_put_contents($path . '/' . $guid, $data['bits']);
     $fileModel = $this->loadModel('files');
     $insertId = $fileModel->insertTable(array('file_name' => $data['name'], 'file_type' => $data['type'], 'file_guid' => $guid, 'file_size' => strlen($data['bits']), 'file_describe' => $data['name']));
     if (!$success) {
         return new IXR_Error(500, '写入' . $data['name'] . '文件时出错.');
     }
     return array('file' => $data['name'], 'url' => $this->stack['static_var']['index'] . '/res/' . $insertId . '/' . $data['name'], 'type' => $data['type']);
 }