function MsgDelFile($cid, $file_id)
{
    session_start();
    $cid = __paramValue('int', $cid);
    $file_id = __paramValue('int', $file_id);
    //    if(!isset($_SESSION['uid'])) return;
    $objResponse = new xajaxResponse();
    if ($result = commune::DeleteAttach($cid, $file_id, true)) {
        $uploaded = commune::GetAttach($cid, true);
        $mess['user_login'] = $_SESSION['login'];
        $page = TPL_COMMUNE_PATH . '/uploaded_files.php';
        ob_start();
        include $page;
        $html = ob_get_contents();
        ob_end_clean();
        $objResponse->assign('uploaded_list', 'innerHTML', $html);
        $objResponse->script('$("files_block").style.display = "block"');
    }
    //        $objResponse->assign('uploaded_list', 'innerHTML', $error);
    return $objResponse;
}
Exemple #2
0
 $request['small'] = 0;
 $request['question'] = $question;
 $request['answers'] = $answers;
 $request['answers_exists'] = $answers_exists;
 $request['multiple'] = $multiple;
 $request['close_comments'] = $close_comments;
 $request['is_private'] = $is_private;
 $small = 0;
 $attach_name = NULL;
 // загрузка файлов
 $files = array();
 $attach = $_FILES['attach'];
 $countfiles = 0;
 if (is_array($attach) && !empty($attach['name'])) {
     $nTotalSize = 0;
     $aAttach = commune::GetAttach($message_id, true);
     if (is_array($aAttach) && count($aAttach)) {
         foreach ($aAttach as $sFile) {
             $nTotalSize += $sFile['size'];
         }
     }
     foreach ($attach['name'] as $key => $v) {
         if (!$attach['name'][$key]) {
             continue;
         }
         ++$countfiles;
         $files[] = new CFile(array('name' => $attach['name'][$key], 'type' => $attach['type'][$key], 'tmp_name' => $attach['tmp_name'][$key], 'error' => $attach['error'][$key], 'size' => $attach['size'][$key]));
         $nTotalSize += $attach['size'][$key];
         if ($nTotalSize > commune::MAX_FILE_SIZE) {
             $alert['attach'] = 'Максимальный объем прикрепленных файлов: ' . commune::MAX_FILE_SIZE / (1024 * 1024) . ' Мб';
             break;