-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to open /results/Sample_07_TemplateCloneRow.docx (windows only) #532
Comments
Hi @AshSat, UPD: |
Any news, @AshSat? |
Hi, I didn't see any issue with the temp dir. Open those 2 documents are the only issues. Thanks a lot ! |
Do you experience the issue with the samples only, or it appears each time you use |
Each time I use TemplateProsessor. |
Which temp dir do you use with PHPWord, default? |
yes, the default one. |
By default, PHPWord uses OS's temp dir. My assumption is that something may happen with file permissions during the trip. So, please, create your own dir somewhere you definetely has enough permissions and give it to PHPWord as temp dir. Maybe this will help. By the way, I use Windows 7 too and can't reproduce the problem. Possibly this is because I work under account with administrator's privileges. |
I cannot comment directly to your exact setup. However, I have had ongoing troubles with temporary files and temporary folders when using PHPWord (not just for templates). I concur that creating and using your own temp folder avoids many problems. |
I tried and it works ! Thank you very much ! Have a very nice day ! |
Hi @AshSat, Could you, please, switch back to the default temp dir, then add Thanks. UPD: finally, the method should look like this. public function saveAs($fileName)
{
$tempFileName = $this->save();
if (file_exists($fileName)) {
unlink($fileName);
}
rename($tempFileName, $fileName);
chmod($fileName, 0666);
} |
Hi Roman, |
Okay, another attempt. 😄 What happens if you copy the file from it's location ( |
@AshSat, are you still there? |
@RomanSyroeshko I also have a broblem,I can't create pdf file.why? |
@kumfo, how this is connected with the issue? |
Hi Roman, |
If we assume that your desktop resides on the same volume ( So, I can suppose that the problem hides somewhere in file path. Can you reveal full file path? Maybe it's simply too long? |
Hi, For now, the only solution working is to create a temporary dir. |
The path looks OK. 😞 Your Windows temp dir is in its default location? |
Yes, it's sad... and my windows temp dir is in its default location.(sorry) |
No pain, no gain. :-) How many Windows users are involved? I use the same user to run Apache, PHP, LibreOffice, everything. It belongs to Administrators, and all the environment was installed under this account. What about you? |
the same... I'm the only user, no other account. All the environment was installed under this account too. |
You know, I even installed WAMP Server, but it didn't help. It just works. 😞 What are the values of |
Requirement check: The keys : I hope it helps :) |
Nope. Mine is "7601.18869.amd64fre.win7sp1_gdr.150525-0603". Home Basic edition. I'll try to find a PC with clean Windows installation. Maybe I customized something on my own laptop and successfully forget about that... |
@AshSat, I got it reproduced on clean installation of Windows 8.1. Will try to find the root cause. |
I'm happy you can reproduce the problem ! |
@AshSat, I found it. Everything works if you change location of temp dirs in Windows (see here for the details). I followed this practice for ages, so it was hard to find. The next thing is about public function saveAs($fileName)
{
$tempFileName = $this->save();
if (file_exists($fileName)) {
unlink($fileName);
}
rename($tempFileName, $fileName);
} with this one public function saveAs($fileName)
{
$tempFileName = $this->save();
if (file_exists($fileName)) {
unlink($fileName);
}
copy($tempFileName, $fileName);
unlink($tempFileName);
} and it helped. It works even with default temp dirs. Could you, please, check if the latter solution works for you? Thanks. |
Sorry, I'm late, I haven't seen your message before :( Thank you very much ! |
Well done, partner! 👍 |
Hi. I think I'm having the same problem. I got this: Uncaught exception 'PhpOffice\PhpWord\Exception\CopyFileException' with message 'Could not copy 'filename.docx' file to 'C:\xx\xx\AppData\Local\Temp\Php2E68.tmp'.' in C:\xampp\htdocs\lyrics\PHPWord-master\src\PhpWord\TemplateProcessor.php: How do I "create your own dir somewhere you definetely has enough permissions and give it to PHPWord as temp dir"? |
Hello,
I have a problem with templates, using a WAMP server.
I don't have any issue with the same process with a LAMP server.
It's a LOCAL application, NOT on the internet.
Word documents have been tested with LibreOffice and OpenOffice, same results.
I'm working with the Sample_07_TemplateCloneRow example.
With Linux :
It works perfectly,
I can open the file via http://...., but it is a "read only" version (that's fine, but NOT what I need)
I can open, read and modify the "/results/Sample_07_TemplateCloneRow.docx" file in his folder (direct access in the folder)
With Windows 7 (I tried with 2 different computers, same issue)
I can open the file via http://, it works but it's NOT what I need !
I can save the document in my "downloads" folder. After that, I can open the new document but it is NOT what I need neither !
I CANNOT open the "c:/[...]/results/Sample_07_TemplateCloneRow.docx", the file is "corrupted" (access denied) but it IS this one I need to open !
After many, many, many tests, I found a way to open those files :
right-click on the file -> Properties -> Security -> Modify -> Add a user -> I added my windows "username" (my OS is in french, i'm not quite sure with the english labels !)
and then, it works, I can open my "c:/[...]/results/Sample_07_TemplateCloneRow.docx"
It works, but it's really not an easy way for a daily use.
Templates (07 & 23) are the only ones who makes troubles.
IE, "/results/Sample_06_Footnote.docx" didn't need any manipulation before beeing open and have no owner neither.
I have no problem with other generated files with or without PHPWord, only with those using TemplateProcessor.
I do not understand what's the problem and think a little bit ironic to have rights/permissions issues with windows...
Has someone a solution with this issue ?
How can I solve it ?
Without this problem, PHPWord is awesome !
Windows 7 64bits
Wamp Server 2.5
Apache 2.4.9 (Win 32)
php 5.5.12
PHPWord Master 0.12.0
The text was updated successfully, but these errors were encountered: