function upload() { $dir = FILES_ROOT . 'all/'; if (!empty($_FILES['file']['name'])) { $file_name = urldecode($_GET['file_name']); $file_type = files::info($_FILES['file']['name'], 'type'); $file_size = files::info($_FILES['file']['tmp_name'], 'size'); db::table('files'); db::insert('', 'NOW()', $file_name, $file_type, $file_size); $file_id = mysql_insert_id(); $file = $dir . $file_id . '.' . $file_type; copy($_FILES['file']['tmp_name'], $file); $file_icon = files::getFileIco($file_type); buffer::set('<p class="load"><img src="/i/fileicons/' . $file_icon . '.png" width="18" height="18" alt="" /> <a href="/download/files/download/?file=' . $file_id . '">' . $file_name . '</a> <span>(' . $file_type . ', ' . round($file_size / 1000) . ' Кб)</span></p>'); } }
function _save() { $file_id = params::get('item_id'); $array = array('file_name' => params::get('file_name'), 'section_id' => params::get('section_id')); db::table('info_files'); db::where('file_id', $file_id); db::update($array); $dir = FILES_ROOT . 'info/'; if (!empty($_FILES['file']['name'])) { $file_size = $_FILES['file']['size']; $file_type = files::info($_FILES['file']['name'], 'type'); $file_name = str_replace('.' . $file_type, '', $_FILES['file']['name']); $file = $dir . $_FILES['file']['name']; copy($_FILES['file']['tmp_name'], $file); $array = array('file_type' => $file_type, 'file_realname' => $file_name, 'file_size' => $file_size); db::table('info_files'); db::where('file_id', $file_id); db::update($array); } headers::self(); }
function uploadFiles() { $dir = FILES_ROOT . 'items/'; if (!empty($_FILES['item_files']['name'])) { $file_size = $_FILES['item_files']['size']; $file_type = files::info($_FILES['item_files']['name'], 'type'); $file_id = md5(date('YmdHis')); $file_name = str_replace('.' . $file_type, '', $_FILES['item_files']['name']); $file = $dir . $file_id . '.' . $file_type; $array = array('file_id' => $file_id, 'file_date' => 'NOW()', 'file_type' => $file_type, 'file_name' => $file_name, 'file_size' => $file_size, 'item_id' => 0); db::table('catalog_items_files'); db::smartInsert($array); copy($_FILES['item_files']['tmp_name'], $file); buffer::set(' <li id="files_id' . $file_id . '"> <input type="hidden" name="files_id[' . $file_id . ']" value="' . $file_id . '"> <img class="vamiddle" src="/i/fileicons/' . files::getFileIco($file_type) . '.png" /> ' . $file_name . '.' . $file_type . ' <a href="javascript:void(null);" onclick="deleteFilesFile(\'' . $file_id . '\');" title="Удалить файл" class="ico ico16 ico_delete"> </a> </li>'); } }