у меня есть этот простой код, который генерирует новый файл .docx из образца с некоторым «токеном» для изменения этого кода, работает на локальном веб-сервере MAMP
$template_file_name = 'template2.docx';
$rand_no = rand(111111, 999999);
$fileName = "results_" . $rand_no . ".docx";
$folder = "results";
$full_path = $folder . '/' . $fileName;
echo $full_path;
try
{
if (!file_exists($folder))
{
mkdir($folder);
}
//Copy the Template file to the Result Directory
copy($template_file_name, $full_path);
// add calss Zip Archive
$zip_val = new ZipArchive;
//Docx file is nothing but a zip file. Open this Zip File
if($zip_val->open($full_path) == true)
{
// In the Open XML Wordprocessing format content is stored.
// In the document.xml file located in the word directory.
$key_file_name = 'word/document.xml';
$message = $zip_val->getFromName($key_file_name);
$timestamp = date('d-M-Y H:i:s');
// this data Replace the placeholders with actual values
$message = str_replace("token1", "text to replace", $message);
//Replace the content with the new content created above.
$zip_val->addFromString($key_file_name, $message);
$zip_val->close();
}
echo "<script type='text/javascript'>alert('file creato');</script>";
}
catch (Exception $exc)
{
$error_message = "Error creating the Word Document";
var_dump($exc);
}
в онлайн-сервере, несмотря на файл и папку 777 привилегий, файл был создан, но без моего текста для замены
в codeigniter я получаю эту ошибку:
$message = $zip_val->getFromName($key_file_name);
![enter image description here](https://i.stack.imgur.com/me2na.png)
$zip_val->addFromString($key_file_name, $message);
![enter image description here](https://i.stack.imgur.com/ayUju.png)
$zip_val->close();
![enter image description here](https://i.stack.imgur.com/lozwr.png)
кто-нибудь может мне помочь? странные вещи, что в веб-сервере в локальной работе без проблем, на веб-сервере онлайн не работает
я надеюсь, что в вашем ответе большое спасибо