파일첨부중 확장자 검사 자바스크립트 (jquery)
function fwrite_submit(f)
{
<?
if ($board1[https_url])
echo "f.action = '$board1[https_url]/$board1[bbs]/write_update.php';";
else
echo "f.action = './write_update.php';";
?>
/*
var s = "";
if (s = word_filter_check(f.wr_subject.value)) {
alert("제목에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
if (s = word_filter_check(f.wr_content.value)) {
alert("내용에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
*/
if (document.getElementById('char_count')) {
if (char_min > 0 || char_max > 0) {
var cnt = parseInt(document.getElementById('char_count').innerHTML);
if (char_min > 0 && char_min > cnt) {
alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
}
else if (char_max > 0 && char_max < cnt) {
alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
}
if (document.getElementById('tx_wr_content')) {
if (!ed_wr_content.outputBodyText()) {
alert('내용을 입력하십시오.');
ed_wr_content.returnFalse();
return false;
}
}
/* 이부분 추가 시작 */
//파일첨부 확장자 소스 (jquery)
var Format= "\.(<?=$config[cf_image_extension]?>)$"; //지정확장자 소스
for(var i = 0; i < $("input[type=file]").length; i++){
if($("input[type=file]").val() == ""){ //파일 올린 내용이 있는지 검사 중에 존재 하지 않는다면
return true;
}else { //파일 올린 내용이 있는지 검사 중에 존재 한다면
if((new RegExp(Format, "i")).test($("input[type=file]").eq(i).val())){ //지정된 확장자가 맞을면 정상
return true;
}else { //지정된 확장자가 틀리면 오류 메세지 발생
alert("이미지 파일(<?=$config[cf_image_extension]?>)만 첨부하실 수 있습니다.");
return false;
}
}
}
/* 이부분 추가 끝 */
var subject = "";
var content = "";
$.ajax({
url: "<?=$board_skin_path?>/ajax.filter.php",
type: "POST",
data: {
"subject": f.wr_subject.value,
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
subject = data.subject;
content = data.content;
}
});
/*
if (subject) {
alert("제목에 금지단어('"+subject+"')가 포함되어있습니다");
f.wr_subject.focus();
return false;
}
if (content) {
alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
if (typeof(ed_wr_content) != "undefined")
ed_wr_content.returnFalse();
else
f.wr_content.focus();
return false;
}
*/
if (!check_kcaptcha(f.wr_key)) {
return false;
}
document.getElementById('btn_submit').disabled = true;
document.getElementById('btn_list').disabled = true;
return true;
}
</script>
<script type="text/javascript" src="<?="$board1[path]/js/board.js"?>"></script>
<script type="text/javascript"> window.onload=function() { drawFont(); } </script>
{
<?
if ($board1[https_url])
echo "f.action = '$board1[https_url]/$board1[bbs]/write_update.php';";
else
echo "f.action = './write_update.php';";
?>
/*
var s = "";
if (s = word_filter_check(f.wr_subject.value)) {
alert("제목에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
if (s = word_filter_check(f.wr_content.value)) {
alert("내용에 금지단어('"+s+"')가 포함되어있습니다");
return false;
}
*/
if (document.getElementById('char_count')) {
if (char_min > 0 || char_max > 0) {
var cnt = parseInt(document.getElementById('char_count').innerHTML);
if (char_min > 0 && char_min > cnt) {
alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
}
else if (char_max > 0 && char_max < cnt) {
alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
}
if (document.getElementById('tx_wr_content')) {
if (!ed_wr_content.outputBodyText()) {
alert('내용을 입력하십시오.');
ed_wr_content.returnFalse();
return false;
}
}
/* 이부분 추가 시작 */
//파일첨부 확장자 소스 (jquery)
var Format= "\.(<?=$config[cf_image_extension]?>)$"; //지정확장자 소스
for(var i = 0; i < $("input[type=file]").length; i++){
if($("input[type=file]").val() == ""){ //파일 올린 내용이 있는지 검사 중에 존재 하지 않는다면
return true;
}else { //파일 올린 내용이 있는지 검사 중에 존재 한다면
if((new RegExp(Format, "i")).test($("input[type=file]").eq(i).val())){ //지정된 확장자가 맞을면 정상
return true;
}else { //지정된 확장자가 틀리면 오류 메세지 발생
alert("이미지 파일(<?=$config[cf_image_extension]?>)만 첨부하실 수 있습니다.");
return false;
}
}
}
/* 이부분 추가 끝 */
var subject = "";
var content = "";
$.ajax({
url: "<?=$board_skin_path?>/ajax.filter.php",
type: "POST",
data: {
"subject": f.wr_subject.value,
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
subject = data.subject;
content = data.content;
}
});
/*
if (subject) {
alert("제목에 금지단어('"+subject+"')가 포함되어있습니다");
f.wr_subject.focus();
return false;
}
if (content) {
alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
if (typeof(ed_wr_content) != "undefined")
ed_wr_content.returnFalse();
else
f.wr_content.focus();
return false;
}
*/
if (!check_kcaptcha(f.wr_key)) {
return false;
}
document.getElementById('btn_submit').disabled = true;
document.getElementById('btn_list').disabled = true;
return true;
}
</script>
<script type="text/javascript" src="<?="$board1[path]/js/board.js"?>"></script>
<script type="text/javascript"> window.onload=function() { drawFont(); } </script>
댓글 7개
하늘바람구름
12년 전
와...좋은 정보 감사합니다...
저에게 꼭 필요한 기능이였습니다...선추천 후적용 해보겠습니다...
저에게 꼭 필요한 기능이였습니다...선추천 후적용 해보겠습니다...
12년 전
good!!!
12년 전
좋은 정보네요~~
12년 전
오 괜춤네요
rumi717
12년 전
감사합니다~
10년 전
위 소스를 넣으니까, $wr_id는 사용할 수 없습니다 에러 뜨네요.
dvga3049
7년 전
감사합니다
게시판 목록
그누4 팁자료실
그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2969 |
|
12년 전 | 4632 | |
| 2968 | 12년 전 | 10530 | ||
| 2967 | 12년 전 | 10910 | ||
| 2966 | 12년 전 | 4311 | ||
| 2965 | 12년 전 | 6752 | ||
| 2964 | 12년 전 | 4505 | ||
| 2963 | 12년 전 | 3923 | ||
| 2962 | 12년 전 | 5717 | ||
| 2961 | 12년 전 | 8605 | ||
| 2960 | 12년 전 | 4600 | ||
| 2959 |
|
12년 전 | 8766 | |
| 2958 |
|
12년 전 | 21435 | |
| 2957 | 12년 전 | 6054 | ||
| 2956 |
|
12년 전 | 13052 | |
| 2955 | 12년 전 | 10441 | ||
| 2954 | 12년 전 | 7459 | ||
| 2953 | 12년 전 | 4697 | ||
| 2952 | 12년 전 | 8059 | ||
| 2951 | 12년 전 | 6774 | ||
| 2950 | 12년 전 | 4856 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기