У меня есть php-форма, которая добавляет значение поля textarea в zip-файл. Он работает хорошо, но не держит линии разрыва. Это мой код:
<script src="//jquery.min.js"></script
<textarea id="txtLicense" placeholder="Licencia">
You are free to use this file
Creative Commons License
</textarea>
<input type="button" value="Send" id="send">
<script>
$("#send").on("click", function(){
var txtLicense = $("#txtLicense").val();
$.ajax({
type: 'POST',
url : 'ajax/zipIt.php',
data: {cmd:"zitTxt", txtLicense:txtLicense},
success: function(data){
console.log(data);
}
});
});
php
<?php
if($_POST['cmd'] == "zitTxt"){
$txtLicense = $_POST['txtLicense'];
$za = new ZipArchive();
$za->open('zips/lic.zip');
$za->addFromString('file.txt', $txtLicense);
$za->close();
echo "ok";
}
?>
Кстати, я уже пробовал использовать "nl2br", но он возвращает ту же строку в одной строке с <br />
внутри:
You are free to use this file <br />Creative Commons License
Любая помощь с этой проблемой будет высоко оценена