2017-05-04 10 views
-1

저는이 문제를 서버의 로컬 파일에 쓰려고하는데 문제가 있습니다. 나는 파일을 작성한 다음 브라우저에서 읽었지만 다른 사람들이 정보를 입력하지 않고 팝업 배너를 실행할 수 있도록 링크를 설정할 수는 없습니다. 여기에 내가 일하고있는 자바 스크립트가있다. 난 선택 윤곽 사용하는 것이 가장 좋은 것은 아니지만 이것은 필수 항목입니다 알아요. 또한 이것은 인터넷이 아닌 로컬 네트워크에서만 작동해야합니다. 이것은 서버에서 실행되며 서버의 파일에 대한 링크는 다른 모든 사람에게 제공되는 것입니다. 그리고 더 많은 페이지가 같은 폴더에서 실행됩니다. 미안합니다. 도와 주셔서 감사합니다.자바 스크립트 파일 쓰기

솔브레드 내 문제는 여기에 있습니다. https://github.com/jimmywarting/StreamSaver.js

   ---------------Test.js file----------- 
function openWin() { 
var myWindow = window.open("", "MsgWindow", "width=2000,height=200,location=no,notoolbar=no,menubar=no,scrollbars=yes,left=0,top=950"); 
var text = document.getElementById('notebox'); 
var image1 = document.getElementById('image1'); 
var image2 = document.getElementById('image2'); 
var imlink = document.getElementById('imlink'); 
var background = document.getElementById('background'); 
var fontsize = document.getElementById('fontsize'); 
var fontcolor = document.getElementById('fontcolor'); 
var fonttype = document.getElementById('fonttype'); 
var fontspeed = document.getElementById('fontspeed'); 
    myWindow.document.write("<marquee behavior='scroll' direction='left' scrollamount='" + fontspeed.value + "' BGCOLOR='" + background.value + "'><h1 style='font-size:" + fontsize.value + "px;color:" + fontcolor.value + ";font-family:" + fonttype.value + ";'><img src='" + image1.value + "' style='width:100px;height:100px;' > " + text.value + " <img src='" + image2.value + "' style='width:100px;height:100px;' ></h1></marquee>"); 
    myWindow.document.close() 
} 
function SaveDatFileBro(localstorage) { 
    localstorage.root.getFile("Banner.html", {create: true}); 
} 


--------------------------------Banner.html--------------------------------- 
<!DOCTYPE html> 
<html> 
<head> 
<title> 
</title> 
</head> 
<body> 

<script src="Test.js"></script> 

<table style="margin:0px auto 0px auto"> 
    <tr> 
     <td><input type="button" value=" Open Banner" onclick="openWin();SaveDatFileBro()"/></td> 
    <td><input type="text" id="notebox" value="Enter Notification" size="120"/></td> 
    </tr> 
    <tr> 
     <td><input type="button" value=" Save Banner" onclick="SaveDatFileBro()"/></td> 
     <td>Font Color:<input type="text" id="fontcolor" value="Red"/> Font Type:<input type="text" id="fonttype" value="Times New Roman"/> Font Size:<input type="text" id="fontsize" value="130" /> Scroll Speed:<input type="text" id="fontspeed" value="25" /></td> 
    </tr> 
     <tr> 
     <td></td> 
     <td>Background Color:<input type="text" id="background" value="White" /> Leading Image:<input type="text" id="image1" value="https://vignette2.wikia.nocookie.net/uncyclopedia/images/4/44/White_square.png/revision/latest/scale-to-width-down/200?cb=20061003200043" /> Trailing Image:<input type="text" id="image2" value="https://vignette2.wikia.nocookie.net/uncyclopedia/images/4/44/White_square.png/revision/latest/scale-to-width-down/200?cb=20061003200043" /></td> 
    </tr> 
</table> 


</body> 
</html> 
+0

서버에 데이터를 저장하려면 서버에서 코드를 실행하여 파일을 저장해야합니다. – epascarello

+0

서버에서 실행되지만 현재 실행중인 로컬 컴퓨터에 저장할 수 없습니다. – Sean

답변

-1

이것은 불가능합니다. 브라우저가 서버의 파일 시스템에 절대 액세스 할 수 없습니다.

서버의 파일 시스템에 기록하려면 HTTP를 통해 브라우저에서 제출 된 데이터를 수신하는 서버 측 프로세스가 필요합니다.