$duoifile = end($arr); if (in_array($duoifile, $loaiduoichophep)) { $tl = new TaiLieu(); $danhmuccon = $_POST['danhmuccon']; $tl->Ten = $ten; $tl->MoTa = $mota; $tl->TacGia = $tacgia; $tl->HinhAnh = $hinhanh; $tl->ThoiGianUpload = $ngayupload; $tl->LoaiFile = $duoifile; $tl->SoTrang = 0; $tl->DanhMucCon = $danhmuccon; $tl->NguoiUpload = $idtaikhoan; //$tl->NguoiUpload = $ //cai nay la do khi co nguoi dang nhap vao thi moi co quyen upload va $kq = $tl->ThemTaiLieu(); $move = move_uploaded_file($_FILES['filesupload']['tmp_name'], 'upload/' . $kq . '.danda'); if ($move) { $thongbao = "Upload files thành công"; $SoTrang = TaiLieu::LaySoTrang('upload/' . $kq . '.danda', $duoifile); TaiLieu::ThemSoTrang($kq, $SoTrang); if ($_FILES['hinhanh']['name'] != "image/icon-ebook.jpg") { $arrha = explode('.', $_FILES['hinhanh']['name']); $duoiha = end($arrha); if ($duoiha == 'jpg') { TaiLieu::ThemHinhAnh($kq, "image/{$kq}.jpg"); move_uploaded_file($_FILES['hinhanh']['tmp_name'], "image/{$kq}.jpg"); } } } else { $error[] = "Lỗi upload";