Forum


Replies: 2   Views: 3619
Createdocxanddownload bug?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jasonva  · 24-02-2014 - 12:15

Hi,



 



If i make a docx file and at the end i use createDocxAndDownload('filename') the downloaded file always have the name document.docx. I think there is a bug in this function because, first there will be checked or $args[0] exists. In the If is on logica, then there will be checked if $args[2] exists, the variable $fileNameAndDownload will be overridden and the document always have the name document.docx



 



My solution is to change te following code:



if (!empty($args[0])) {

            $fileName = $args[0];

            $completeName = explode("/", $args[0]);

            $fileNameDownload = array_pop($completeName);

        } else {

            $fileName = 'document';

            $fileNameDownload = 'document';

        }

        if (!empty($args[2])) {

            $fileNameDownload = $args[2];

        } else {

            $fileNameDownload = 'document.docx';

        }



 



to this:



if (!empty($args[0])) {

            $fileName = $args[0];

            $completeName = explode("/", $args[0]);

            $fileNameDownload = array_pop($completeName) . '.docx';

        } else {

            $fileNameDownload = 'document.docx';

        }



 



Do anybody else have the same problem?