Selaa lähdekoodia

checkFileSize 파일 용량 체크

bin2107 4 vuotta sitten
vanhempi
commit
06ad63a7e0

+ 19 - 1
src/main/webapp/WEB-INF/views/display/MainContentsPopupForm.html

@@ -973,6 +973,10 @@
 
 	var fnVideoFileUpload = function (obj, idx){
 		var file = obj.files[0];
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
 		gagaKollus.upload('Display', file, $(obj).find('input[name=kufKey]'));
 	}
 
@@ -1521,6 +1525,11 @@
 	 */
 	var fnPopFileUpload = function (obj, ind){
 		var file = obj.files[0];
+
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
 		file.name = 'test';
 		if (typeof(file) == 'undefined'){
 			return;
@@ -1543,6 +1552,12 @@
 	 */
 	var fnGnbFileUpload = function (obj, ind, num){
 		var file = obj.files[0];
+
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
+
 		file.name = 'test';
 		if (typeof(file) == 'undefined'){
 			return;
@@ -1847,8 +1862,11 @@
 
 	// 동영상파일 선택 시
 	$('#popSortable input[name=file]').on('change', function() {
-		console.log('888');
 		var file = this.files[0];
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
 		gagaKollus.upload('Display', file, $('input[name=kufKey]'));
 	});
 

+ 8 - 0
src/main/webapp/WEB-INF/views/display/MainMultiContentsPopupForm.html

@@ -454,6 +454,10 @@ console.log('brandGroupNo:'+brandGroupNo);
 	 */
 	var fnBrandImgFileUpload = function (obj, ind){
 		var file = obj.files[0];
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
 		file.name = 'test';
 		if (typeof(file) == 'undefined'){
 			return;
@@ -584,6 +588,10 @@ console.log('brandGroupNo:'+brandGroupNo);
 	// 기획전/배너 파일첨부
 	var fnPlanFileUpload = function (obj, ind){
 		var file = obj.files[0];
+		// 파일 용량 체크 10MB
+		if(!gagajf.checkFileSize(file)){
+			return;
+		}
 		file.name = 'test';
 		if (typeof(file) == 'undefined'){
 			return;

+ 16 - 0
src/main/webapp/ux/plugins/gaga/gaga.validation.js

@@ -1041,6 +1041,22 @@ var gagajf = {
 		});
 
 		return arrValue;
+	} ,
+	checkFileSize : function (obj, data){
+		var isInvalid = true;
+
+		var fileSize = data.size;
+		var maxSize = 1024 * 1024 * 10;
+		if(fileSize > maxSize){
+			alert("파일용량이 10MB을 초과했습니다.");
+			isInvalid = false;
+			return false;
+		}else{
+			isInvalid = true
+			return true;
+		}
+
+		return isInvalid;
 	}
 };