티스토리 뷰
* 프린트 스크린후 웹페이지에 붙여넣기
<?php
if($_REQUEST['mode']=='paste'){
if( isset( $_FILES['file'] ) ) {
$file_contents = file_get_contents( $_FILES['file']['tmp_name'] );
header("Content-Type: " . $_FILES['file']['type'] );
die($file_contents);
}
else {
header("HTTP/1.1 400 Bad Request");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Paste Capture 'Image'</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<style>
.output{float:left;padding:10px;width:49%;height:300px;text-align:center;overflow:hidden;border:1px solid #ccc;background-color:#f5f5f5;}
.output::before{content:"[base64] 화면 캡쳐후 붙여넣기 해주세요.(Print Screen -> Ctrl+V)";display:inline-block;margin-top:5%;}
.output.paste{height:auto;}
.output.paste::before{display:none}
.output img{max-width:100%;}
#output2.output{float:right;}
#output2.output::before{content:"[blob] 화면 캡쳐후 붙여넣기 해주세요.(Print Screen -> Ctrl+V)"}
</style>
<script>
$(function(){
var $output=document.querySelector("#output")
,$output2=document.querySelector("#output2");
// base64 encode 되어 브라우저가 읽어 들임
// https://stackoverflow.com/questions/6333814/how-does-the-paste-image-from-clipboard-functionality-work-in-gmail-and-google-c
$output.onpaste = function(event){
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
//console.log(JSON.stringify(items)); // will give you the mime types
for (index in items) {
var item = items[index];
if (item.kind === 'file') {
var blob = item.getAsFile();
var reader = new FileReader();
// data url!
reader.readAsDataURL(blob);
reader.onload = function(event){
$output.className="output paste";
var img=new Image();
img.src=event.target.result;
$output.appendChild(img);
};
}
}
}
// blob 타입 이미지로 서버에서 직접 읽어들임
// https://stackoverflow.com/questions/18055422/how-to-receive-php-image-data-over-copy-n-paste-javascript-with-xmlhttprequest
$output2.onpaste = function (e) {
var items = e.clipboardData.items;
var files = [];
for( var i = 0, len = items.length; i < len; ++i ) {
var item = items[i];
if( item.kind === "file" ) {
submitFileForm(item.getAsFile(), "paste");
}
}
};
function submitFileForm(file, type) {
var extension = file.type.match(/\/([a-z0-9]+)/i)[1].toLowerCase();
var formData = new FormData();
formData.append('file', file, "image_file");
formData.append('mode', 'paste' );
formData.append('extension', extension );
formData.append("mimetype", file.type );
formData.append('submission-type', type);
var xhr = new XMLHttpRequest();
xhr.responseType = "blob";
xhr.open('POST', '<?php echo basename(__FILE__); ?>');
xhr.onload = function () {
if (xhr.status == 200) {
$output2.className="output paste";
var img = new Image()
,url=(window.URL || window.webkitURL);
img.src = url.createObjectURL( xhr.response );
img.onload=function(e){
url.revokeObjectURL(this.src); // blob 메모리 해제
};
$output2.appendChild(img);
}
};
xhr.send(formData);
}
});
</script>
</head>
<body>
<div class="container-fluid">
<h1>Paste Capture 'Image' <a href="http://nosmoke.tistory.com/2490" target="_blank" class="label label-info">설명</a></h1>
<div id="output" class="output"></div>
<div id="output2" class="output"></div>
</div>
</body>
</html>
'컴터 > html5' 카테고리의 다른 글
input type="file" 폴더 업로드 (webkitdirectory directory) (0) | 2016.05.17 |
---|---|
input type="number" 에서 소수점 입력하고 전송시 유효성검사 통과에 막힐때? (0) | 2014.01.20 |
js canvas로 만든 간단한 bar 형태 챠트 (0) | 2011.09.23 |
[html5] 안드로이드 브라우저에서 video 태그 사용하기 (2) | 2010.09.10 |
- Total
- 1,770,491
- Today
- 3
- Yesterday
- 19
- Adobe AIR / www.AS3.kr / Actio…
- Adobe AIR Devpia.
- Beyond Tomorrow
- Blog of Shigeru Nakagaki. Let\…
- CSS3 . Info
- Code Weblog
- CodeIgniter 한국사용자포럼 BETA
- ECONOBLOG
- FlexComponent-플렉스 네이버 카페
- Guru's Blog
- Hooney.net - CSS Reference Sit…
- Korean Healthlog
- Raymond.CC Blog
- [Air]AIR_IN_ACTION
- [CSS]후니넷
- [Flex] css 스킨
- [JavaFx] 한글화
- [basic4ppc]괜찮은 사이트
- [flex2책저자]with okgosu (-..-)a
- [flex] stylesheet
- [flex] 예제 많은곳-EBook관련
- [flex]ungsung' study
- [html5-canvas]『 zeroone 』blog
- [html5-iphone]xguru.net
- [html5]korea html5 group
- [html5]sencha touch demos - fr…
- [iPhone]아이군의 블로그
- [iphone] 토리의 놀이터
- [iphone]LambertPark
- [iphone]safari 레퍼런스
- [iphone]피의복수
- [jQuery Plugin] 포토갤러리
- [jQuery] -- jQuery
- [jQuery] 1.1.2 API Browser
- [jQuery] IBM 사이트 설명
- [jQuery] 예제 많음
- [javascript]JKwang's Programs
- [red5]
- [그래픽js] 끝내줌.ㅋ
- [김프]무료 이미지 관리툴 -비교대상 포토샵
- [무료캡쳐프로그램] jing Project - swf …
- [무료호스팅]1.5Gb 줌
- [서프라이즈] - 대문
- [실버라이트] msdn
- [실버라이트]ONESTONE
- [실버라이트]ZZANGMYON BLOG♡
- [실버라이트]사진속에 혼을 담는 개발자
- [실버라이트]유령회사 공도소프트
- [실버라이트]이과장의 프로그래밍이야기
- [오픈소스검색엔진]루씬 한글분석기 오픈소스 프로젝트
- [해킨토시]x86osx.com
- adobe 예제 사이트
- d-|-b First Of May
- lovesera.com: ART of VIRTUE
- rollin96님의 노트-air/flex Tip
- w3school.com
- 굿네이버스
- 꿀뷰, 바닥, 술집의 개발자
- 나물이네-자취생들의 먹거리 해결..ㅋ
- 낙장불입 인생막장
- 내 눈으로 본 한국, 한국인....
- 딴동네-Air/Flex 영상 강좌
- 레인 에디터
- 류종택의 프로그래밍 강의실
- 리아 코리아
- 무료 호스팅 해줌 - 디지문
- 버터백통의 Action Script 레시피
- 살아 숨 쉬는 웹 - 블루비
- 색깔있는 진보 칼라TV
- 시작하세요! iphone3
- 아이디어 상품
- 아폴로케이션[Adobe AIR]
- 엑셀 도움말
- 영원의 헤아림-검쉰-Flex
- 오픈소스 FLV 플레이어
- 울나라 Ajax Library
- 웹사이트 방문자 통계
- 웹카페-css 잘나왔뜸
- 웹캠으로하는 멋진 게임
- 웹프로그래머의 홈페이지 정보 블로그
- 윤훈남의 액션스크립트3.0
- 조인시 위키
- 체리필터의 인생이야기
- 충청투데이 알짜 뉴스
- 칸과칸사이
- 태우\'s log - web 2.0 and beyond
- 파비콘 제네레이터
- 파인애플 밴드
- 팬소년이야기
- 한국의 대표 진보언론 민중의소리 - 전체 기사
- 훈스닷컴
- Feeding.kr의 일용할양식
- [javascript]기억하고 싶은 것들
- XML-RPC-metaWeblog 설명
- [IT웹툰]미닉스의 작은 이야기들
- outsider 개발자
- 애매한 발음 알아볼때
- [android]Photographer. Android…
- [android]mSurf Lab 안드로이드 개발 정보…
- [android]안드로이드 개발 정보
- [android]안드로이드 개발하는놈
- [android]안드로이드 프로그래밍 정복
- [android]참 쉽습니까?
- [android]커니의 안드로이드 이야기 - Andro…
- [android]회색의 구글 안드로이드 개발
- 장군블로그 [진심을 담는 마크업. 웹 표준. 웹 접근성…
- 백남중
- NARADESIGN:BLOG
- [php.js] php함수 js로 옮겨놓은 곳
- javascript 이론적으로 설명잘해놓은곳
- JavaScript Garden
- Angularjs 등 javascript 설명
- node.js
- 유용한 코드 많은 곳...코드쪼가리?
- HTML5 Demos- 최고!!!
- Firejune - The Web is still ch…
- 글읽어주는 사이트
- [publisher] Clearboth
- [nodejs]Hello World!!
- angularjs2 - 강추
- 모든 브라우저에서 동작하는 canvas
- Beautiful Jquery Plugin MopTip…
- 김진형교수의 SW정책 단상
- Comments for 미스타표, 즐기며 배우며.
- [외국개발자]곰같은블로그
- [opencv]다크 프로그래머
- [YouTube]日本人の知らない日本語
- 영어학습 자료실 EnglishCube - 추천사이트, …
- がんばれ! 日本語
- [youtube]serina hwang
- 하라마~~~
- O HOUSE : 라이프 매거진
- 아름다운 하우스 : 네이버 블로그
- [인테리어]김반장의 이중생활
- [리모델링]Pastel design & Archi te…
- [리모델링]대전 아파트 인테리어 전문 업체! 엘림하우스
- [리모델링]가람홈스토리
- :: Back to the Mac
- Swift 언어 개발문서
- [swift]Seorenn SIGSEGV
- Swift Lab를 위한 댓글
- 콩닥맘의 차니스토리 : 네이버 블로그
- 헬렌의 테이스팅 메뉴 The Tasting Menu
- lovesera: ART of VIRTUE-정진호
- [ionic] saltfactory's blog
- PhoneGap API Documentation
- 김변의 법인등기 : 네이버 블로그
- 면어의 얼렁뚱땅 캘리그라피
- 푸른지성과 카즈미, 그리고 코타의 행복한 세상!
- AnimationKING
- AnimationKING : 네이버 블로그
- POND X P.B.Y
- 도쿄 동경 베쯔니 블로그
- whatdo.net-티티호스팅
- 자양동
- 쌍둥이빌딩
- ogv
- 충청투데이
- 봄
- html5
- 안드로이드
- 겨울준비
- 대전역
- 넥서스원
- flex
- 가오지구
- 재개발
- Alert.show
- 아이폰
- 자전거
- jQuery
- 고려극장
- html5예제
- php
- Ajax
- 공개
- AIR
- 맥북에어 13
- exif 정보
- 골목
- 해킨토시
- localstorage
- 사마귀
- 티눈