이것은 꽤 오래되었지만 현재 동일한 문제를 해결하고 있기 때문에 어쨌든 답할 수있을 것이라고 생각했습니다. 이를 수행하는 올바른 방법은 수정 된 파일을 키/값 저장소에 저장하는 것입니다 (Web Storage - http://www.w3.org/TR/webstorage/).
원래 파일을 교체해야하는 경우 웹 서버를 거쳐 수정 된 파일을 웹 서버의 올바른 URL에 넣거나 게시해야합니다. 이것은 사소한 백엔드를 작성하여 파일을 가져 와서 저장하는 것을 의미합니다.
다음은 간단한 저장 코드 - 당신은 코드에서 적절한 위치에있는 파일에 대한 URL과 파일 이름을 삽입해야합니다 :
이
<!DOCTYPE html>
<html>
<head>
<title>File editor</title>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.4.1");
</script>
<script>
$(document).ready(function() {
// check to see if we have it in storage already
if (file = localStorage.getItem('<filename>')) {
$("textarea[id='edit_box']").val(file);
} else { // get it from the url
$.get("<url to file>", null, function(data)
{
$("textarea[id='edit_box']").val(data);
}, "text");
}
// save to storage
$("textarea[id='edit_box']").bind('keyup', function() {
localStorage.setItem('<filename>', this.value);
});
});
</script>
</head>
<body>
<form method="get" id="edit_file">
<input type="file"></input>
<div id="edit">
<textarea id="edit_box" placeholder="Type here" cols="80" rows="50"></textarea>
</div>
</body>
</html>
출처
2011-11-18 00:07:50
Guy
아니라, 플래시가 더 이동하지 않습니다. 이 프로젝트에 html5 기술을 사용해야합니다. – boris