alert('".$file."');"; if (file_exists($file)) { unlink($file); file_put_contents($file, $contents) or die ("Error"); mysql_query("update keepit_docbank set title='$title' where id='$id' and owner='$owner'") or die(mysql_error()); } else { $query = mysql_query("insert into keepit_docbank (id,title,container,owner,type) values('$id','$title','$dir','$owner','cascade')") or die("Can't connect: ".mysql_error()); file_put_contents($file, $contents) or die ("Error"); } /*$fh = fopen($file, 'w'); fwrite($fh, $contents); fclose($fh);*/ echo "All changes saved!"; ?>