웹마스터 팁

그냥재미로님의 모바일 파일 업로드 지원 게시판이 있는데

요걸 잘하면 스케치북5 모바일 게시판도 업로드가 가능 하게 할 수 있지 않을 까해서

끄적이다 아주그냥 대공사를 하고 말았습니다 ㅠㅠ


테스트 기종

아이폰4S IOS 5.1.1

갤석시S3 4.1

모두 이상 없이 잘됩니다.


먼저 write_form.html 8번째 줄

<!--%import("css/board.css")-->

밑에 추가 해줍니다.

<!--%import("./js/ajaxfileupload.js")-->

<?php
include_once(_XE_PATH_.'/modules/file/file.class.php');
include_once(_XE_PATH_.'/modules/file/file.controller.php');
$oFileController = &getController('file');

if(!$_SESSION['_editor_sequence_']) $_SESSION['_editor_sequence_'] = 1;
$editor_sequence = $_SESSION['_editor_sequence_'] ++;
$oFileController->setUploadInfo($editor_sequence, $upload_target_srl);
$_SESSION['upload_info'][$editor_sequence]->enabled = true;
$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl;
?>
<style type="text/css">
.success {
border-width: 1px;
border-style: dotted;
border-color: blueViolet;
padding: 10px;
}
.success img {
display: block;
}
.success a {
margin-left: 10px;
font-weight: bold;
}
</style>
<script type="text/javascript" >
jQuery.extend({
    handleError: function( s, xhr, status, e ) {
        // If a local callback was specified, fire it
        if ( s.error )
            s.error( xhr, status, e );
        // If we have some XML response text (e.g. from an AJAX call) then log it in the console
        else if(xhr.responseText)
            console.log(xhr.responseText);
    }
});
	function ajaxFileUpload()
	{
		if(document.getElementById('Filedata').value ==""){
			alert("파일을 선택하세요");
			return false;
		}

		var up=jQuery("#t_document_srl").attr("value");

		jQuery.ajaxFileUpload
		(
			{
				url:'index.php?&act=procFileIframeUpload',
				secureuri:false,
				fileElementId:'Filedata',
				dataType: 'html',
				data:{
				mid: '{$mid}',
				editor_sequence: '1',
				uploadTargetSrl: up,
				manual_insert: 'true'
				},
				success: function (frameId, data, status)
				{
				var frm = document.getElementById('ff');
				var io = document.getElementById(frameId);			
				if(io.contentWindow)
				{
					var sourceFile = document.getElementById(frameId).contentWindow.uploaded_fileinfo.source_filename;
					var uploadFile = document.getElementById(frameId).contentWindow.uploaded_fileinfo.uploaded_filename;
					var document_srl = document.getElementById(frameId).contentWindow.uploaded_fileinfo.upload_target_srl;				
					var file_srl = document.getElementById(frameId).contentWindow.uploaded_fileinfo.file_srl;

				}else if(io.contentDocument)
				{
					var sourceFile = document.getElementById(frameId).contentDocument.uploaded_fileinfo.source_filename;
					var uploadFile = document.getElementById(frameId).contentDocument.uploaded_fileinfo.uploaded_filename;
					var document_srl = document.getElementById(frameId).contentDocument.uploaded_fileinfo.upload_target_srl;									
					var file_srl = document.getElementById(frameId).contentDocument.uploaded_fileinfo.file_srl;
				}
				//frm.document_srl.value = document_srl;

				jQuery("#t_document_srl").attr("value",document_srl);

			//	document.getElementById('Filedata').value ='aaa';
				
				if(uploadFile != ""){
					var Extension = uploadFile.substring(uploadFile.lastIndexOf('.') + 1).toLowerCase();
					if (Extension == "gif" || Extension == "png" || Extension == "bmp" || Extension == "jpeg" || Extension == "jpg") {
					jQuery('<li id="'+file_srl+'" class="wrt_opt"></li>').appendTo('#files').html('<img width="50px" height="atuo" src="'+uploadFile+'" /><span class="filename">'+sourceFile+'</span><a href="javascript:delete_file('+file_srl+',1)" class="abn dark">{$lang->cmd_delete}</a>').addClass('success');
					}
					else
					{
					jQuery('<li id="'+file_srl+'" class="wrt_opt"></li>').appendTo('#files').html('<span class="filename">'+sourceFile+'</span><a href="javascript:delete_file('+file_srl+',1)" class="abn dark">{$lang->cmd_delete}</a>').addClass('success');
					}
				} else{
					jQuery('<li></li>').appendTo('#files').text(sourceFile).addClass('error');
				}
				
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							alert(data.error);
						}else
						{
							alert(data.msg);
						}
					}
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			}
		)
		
		return false;

	}
	
	function frmSubmit(){
		var frm = document.getElementById('ff');
		procFilter(frm, insert);
	}	
	
function delete_file(file_srl,editorSequence){
	
	var msg = window.confirm('삭제하시겠습니까?');
	if(msg)
	{
		var settings = file_srl;
	    var params = new Array();
	    params["file_srls"]  = file_srl;
	    params["editor_sequence"] = editorSequence;
	    var response_tags = new Array("error","message");
	    exec_xml("file","procFileDelete", params, function() { reloadFileList(settings); } );
	}else{
		return false;
	}

}
function reloadFileList(settings) {
	jQuery("#"+settings).remove();
}
jQuery($).ready(function($){
	$("#loading_dialog")
	.ajaxStart(function(){
		$(this).show();
		$("#loading_form").hide();
	})
	.ajaxComplete(function(){
		$(this).hide();
		$("#loading_form").show();
	});
});
</script>



그 다음 같은 파일에서

<li>

<label for="nText">{$lang->content}</label>

<textarea name="content" cols="20" rows="8" id="nText"></textarea>

</li>

요렇게 생긴 놈 밑에 추가 합니다.

			<ul id="files" >
			</ul>
			<li class="wrt_locate">
				<div id="loading_dialog" style="display:none">
					<img id="loading" src="./img/loading.gif">
					<p>잠시만 기다려 주세요</p>
				</div>
				<div id="loading_form">
				<label for="nFileUpload">파일첨부</label>
					<input id="Filedata" type="file"  name="Filedata" class="input" style="width:100%;" value="">
					<button type="button" id="buttonUpload" onclick="return ajaxFileUpload();" class="btn">파일 업로드</button>
					<p>파일을 먼저 업로드하신 후 등록하세요</p>
				</div>
			</li>


그다음은 ./js/ 폴더에

ajaxfileupload.js

이 파일을 올려 줍니다.


아마도 이렇게 하면 됩니다.


이게 힘들다 싶으면

sketchbook5Mobile.zip

이파일을 덮어 쓰셔도 됩니다.

제목 글쓴이 날짜
게시판 글작성 및 댓글작성이 안될때 [2] 똑디 2012.10.18
닉네임 변경시 기존 게시물 연동 팁 (레벨 아이콘 에드온 이용) [9] 바붕아 2012.10.23
[XE 1.4] 모듈 개발 시 유의해야할 템플릿 버그 퍼니엑스이 2012.10.24
330 오류(net::ERR_CONTENT_DECODING_FAILED): 알 수 없는 오류 - 해결책 [2] 하얀마법 2012.10.25
실명제 사이트 만들기 [5] Hojoon Chang 2012.10.28
bodex 추천 & 댓글 버튼 만들기. [1] file meanie 2012.10.28
XE 다국어로 페이지/글 작성하기 [4] jhrun 2012.11.05
Nginx 에서 파일 업로드시 message: 413 에러 해결법 [3] 루트엘 2012.11.08
사이트 내 닉네임을 일괄 변경하기 [6] 윈컴이 2012.11.09
로그인 실패 관련 쪽지 또는 메일이 안 날라오게 하는 방법 [9] sejin7940 2012.11.12
exec_xml is not defined 오류 해결책 한마음^^ 2012.11.16
닉네임, 레벨, 포인트등 활동정보바 [2] file 소렌트. 2012.11.19
소셜XE에 지쳐서 찾다 찾다 찾은게 [4] SuperSonic 2012.11.21
xe에서 폼메일 구성하려는데 폼메일을 사용하려면 메일서버는 어떻게 ? 폼메일 2012.11.23
본문내 이미지 조절 애드온 기능 확장 - 원본이미지 모달 제거 / 작은이미지 크게 확장하기 [2] sejin7940 2012.11.25
일반게시판에서 모듈게시판 혹은 모듈게시판(에서 일반게시판예로들어 일반게시판 -> 게시판DX 혹은 그 반대)으로 게시글 이동시키는 방법 (DB에서) [1] file 장포크 2012.11.28
Sketchbook5 모바일 게시판에 파일 업로드 기능 추가 하기 [14] file hhgyu 2012.11.28
회원가입 버튼을 누르면 출력되는 Can not open GeoIP.dat 에러 대처방법(임시) [2] 마음의빈자리 2012.11.30
위젯 <td> 마다 다르게 배경색 지정.. [1] 제임스라 2012.11.30
템플릿 cond 문법에 else를 넣어봅시다. <block cond="else"></block> [2] 엘카 2012.11.30