Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- tomcat
- input
- MySQL
- ajax
- Spring
- CentOS
- 이클립스
- File
- jquery
- NetBeans
- properties
- html
- java
- laravel
- Linux
- junit
- JSON
- larravel
- 안드로이드
- error
- 톰캣
- javascript
- SeLinux
- 정규식
- Android
- curl
- php
- 와일드카드
- DB
- 리눅스
Archives
- Today
- Total
합쭈기 programming
iframe 파일전송 본문
//ie 때문에
$("#personFile").change(addPic);
function addPic()
{
form = document.createElement("form");
form.name = "formFile";
form.action = "/";
form.method = "post";
form.enctype="multipart/form-data";
form.encoding="multipart/form-data";
var file = $(this);
$(file).attr("name", "personFile");
temp = $(this).parent();
$(form).append($(file));
var frameName = 'unique' + (new Date().getTime()); //generate a random name
var $frame = $('<iframe>', {
src: "javascript: false;",
name: frameName
}).appendTo('body').hide();
$frame.append(form);
var pt = navigator.userAgent.indexOf('MSIE');
if (pt != -1 ){
if (Number(navigator.userAgent.substring(pt+5,pt+8)) > 8)
form.target = frameName;
}else
form.target = frameName;
form.submit();
$frame.load(function(e) {
var doc = getDoc($frame[0]);
var docRoot = doc.body ? doc.body : doc.documentElement;
var data = docRoot.innerHTML;
msg = $.parseJSON(data);
$("input[name=personFileGroupId]").val(msg.fileGroupId);
$(".pic span").html('<img src="/img?imgName='+msg.fileName+'" width="170" height="175" />');
doc.close();
$('#fileWrap').append('<input type="file" name="files" id="personFile" />');
$('#fileWrap').children('#personFile').change(addPic);
$(this).remove();
});
}'Javascript' 카테고리의 다른 글
| Print (0) | 2015.04.13 |
|---|---|
| 정규식 숫자만 표현 (0) | 2015.04.13 |
| Modal 띄우기 (0) | 2015.04.13 |
| Daum 주소검색 서비스 (0) | 2015.04.13 |
| ajax와 ajax form (0) | 2015.04.13 |