$uploader = new XoopsMediaUploader($files_dir, $allowed_mimetypes, $maxfilesize); foreach ($_POST["xoops_upload_file"] as $k => $v) { if ($uploader->fetchMedia($v)) { $uploader->setPrefix('support_'); if (!$uploader->upload()) { echo $uploader->getErrors(); } else { $att_obj =& $att_handler->create(); $att_obj->setVar('res_id', $res_id); if (!empty($xoopsUser)) { $att_obj->setVar('uid', $xoopsUser->getVar("uid")); } $att_obj->setVar("att_filename", $uploader->getMediaName()); $att_obj->setVar("att_attachment", $uploader->getSavedFileName()); $att_obj->setVar("att_type", $uploader->getMediaType()); $att_obj->setVar("att_size", $uploader->getMediaSize()); $att_obj->setVar("grate_time", time()); $att_obj->setVar("update_time", time()); $att_handler->insert($att_obj); $att_num = $att_num + 1; } unset($att_obj); } } //update resources res_attachment $res_obj =& $resources_handler->get($res_id); $res_obj->setVar('res_attachment', $att_num); $resources_handler->insert($res_obj); } redirect_header('admin.resources.php', 3, '保存成功'); }