Okay, I'm just a little newbie in programming just doing it for a past time hobby. I am just recently making a web editor for fun and the way I was doing it (Using PHP) I was told would be a bad way. I also thought about it while I was making it, and in massive sums of data transfer it would be a bad idea to do it this way. Thing is I can't think of another way to do it and was looking for someone to help me improve it, by it I mean my save method I am using. Here my codes:
Editor:
<html>
<head>
<title>Web Editor</title>
<link href="controller.css" rel="stylesheet"/>
<script type="text/javascript" src="script/editor.js"></script>
</head>
<body>
<div class="platform">
<div class="head"><div class="file"><p>File: <div id="file">C:\hello.html</div></p></div></div>
<div class="hotbar"><img src="images/save.png" class="hotbarImage" onClick="save()" />
</div>
<div class="editor"><div contenteditable="true" style="height:100%; overflow:scroll;" id="editPad"></div></div>
</div>
</body>
</html>
JS:
function save() {
var dir = document.getElementById("file").innerHTML;
var data = document.getElementById("editPad").innerHTML;
window.location = "save.php?dir="+encodeURIComponent(dir)+"&data="+encodeURIComponent(data);
}
PHP:
<?php
$dir = $_GET['dir'];
$data = $_GET['data'];
$lookFor = array("<", ">","<br>","<%2Fdiv>","<div>","</div>");
$replaceWith = array("<", ">", "", "", "","");
$newData = str_replace($lookFor,$replaceWith,$data);
$f = fopen(urldecode($dir),"w");
fwrite($f,urldecode($newData));
fclose($f);
?>
All of it is just a work in progress and need more done. But for right now, is there a better way for me to save the file with massive sums of data being transfer.