function create_checked($file, $forum_id, $mimetype = 'application/octetstream') { global $user; if (!file_exists($file)) { trigger_error('FILE_NOT_FOUND', E_USER_ERROR); } $filedata = array('realname' => basename($file), 'size' => filesize($file), 'type' => $mimetype); $filedata = upload_attachment(false, $forum_id, true, $file, false, $filedata); if ($filedata['post_attach'] && !sizeof($filedata['error'])) { $attachment = new attachment(); $attachment->poster_id = $user->data['user_id']; $attachment->physical_filename = $filedata['physical_filename']; $attachment->real_filename = $filedata['real_filename']; $attachment->extension = $filedata['extension']; $attachment->mimetype = $filedata['mimetype']; $attachment->filesize = $filedata['filesize']; $attachment->filetime = $filedata['filetime']; $attachment->thumbnail = $filedata['thumbnail']; $attachment->submit(); return $attachment; } else { trigger_error(implode('<br/>', $filedata['error']), E_USER_ERROR); } }