XE 모듈에서 파일 업로드 방법
CMS/프레임워크 | Rhymix 1.9 |
---|---|
개발 언어 | PHP 7.2 |
XE 모듈을 제작하고 있는데요, XE 파일모듈이랑 연동을 해서 이미지를 서버로 업로드 하고 싶습니다.
혹시 예제라던지 참고할만한 모듈이 있을까요?

리버스
Lv. 7
모듈만드는 대학생입니다.
https://potatosoft.kr
https://potatosoft.kr
CMS/프레임워크 | Rhymix 1.9 |
---|---|
개발 언어 | PHP 7.2 |
XE 모듈을 제작하고 있는데요, XE 파일모듈이랑 연동을 해서 이미지를 서버로 업로드 하고 싶습니다.
혹시 예제라던지 참고할만한 모듈이 있을까요?
댓글 5
https://xe1.xpressengine.com/index.php?mid=download&package_id=22753684
자료가 있는데 벌써 3년이 넘어서 현재 잘 작동되는지는 모르겠네요
그 외에는.. 제 자료도 있긴한데
http://sejin7940.co.kr/index.php?mid=sejin7940_work&category=109909
이건 제작의뢰 받았을때만 사용하는거여서 분석용으로는 도움이 안 될거예요 ^^;
그 외에는 따로 제작된 예는 잘 모르겠네요
Core 수정으로 구현한 분들도 계실지도..
저는 예전에 쪽지함에서 파일전송하는 구현을 하였었는데... 작동은 잘 되었습니다....
혹시 몰라 아래에 소스 남깁니다.
{@
$module_info = Context::get("module_info");
$module_srl = $module_info->module_srl;
$upfile= Context::get("input_imgs");
$upload_target_srl = "000";
$oFileController = getController('file');
$output = $oFileController->insertFile($upfile, $module_srl, $upload_target_srl);
$output2 = $output->variables[uploaded_filename];
}
<!--@if($output->error=="-1")-->
<script>alert("{$output->message}");</script>
<!--@else-->
<script>$(function () {
$("#title").val('이미지파일ㅤ');
document.getElementById("content").value = '{$output2}';
$.ajax({
type: 'post',
url: '',
data: $('form').serialize(),
success: function () {
var url = location.href + " #container2";
$("#container").load(url);
}
});
document.getElementById("content").value = '';
});</script>
<!--@end-->
</block>
<div id="footer">
<input name="input_imgs" type="file" id="input_imgs" multiple/>
<a href="javascript:" onclick="fileUploadAction();">
<div class="imgbtn"><img class="file" src="img/file.png"></div></a>
<div class="textarea">
<textarea class="edt" style="margin-top:10px;" id="content" name="content" rows="4" cols="2000"></textarea>
<input type="hidden" id="title" name="title" value=""/>
</div>
<div class="sendbtn">
<input class="send" id="send" type="image" src="img/send.png">
</div>
</div>
</form>
var sel_files = [];
$(document).ready(function() {
$("#input_imgs").on("change", handleImgFileSelect);
});
function fileUploadAction() {
console.log("fileUploadAction");
$("#input_imgs").trigger('click');
}
function handleImgFileSelect(e) {
// 이미지 정보들을 초기화
sel_files = [];
$(".imgs_wrap").empty();
var files = e.target.files;
ff = '1';
$("#send").trigger('click');
}
소스 감사합니다!
두번째 소스의 경우 해당 이미지(파일)을 업로드 하는 폼 입니다. (html상에서 파일의 위치, 바이너리 등을 가져오는 부분이라고 생각하면 됩니다.)
세번째 소스의 경우 자바스크립트를 이용한 이미지처리 과정 입니다.
{@
$module_info = Context::get("module_info");
$module_srl = $module_info->module_srl;
$upfile= Context::get("input_imgs");
$upload_target_srl = "000";
$oFileController = getController('file');
$output = $oFileController->insertFile($upfile, $module_srl, $upload_target_srl);
$output2 = $output->variables[uploaded_filename];
}
실제로 XE에서 파일을 등록하는 컨트롤부 소스는 위의 부분 입니다.