Home » File Formats » File_Archive » Bug #4157
File_Archive::toArchive Pass by reference error
Details
| Submitted | 2005-04-15 20:02 UTC |
|---|---|
| From | dmytton at php dot net |
| Assigned | vincentlascaux |
| Status | Closed |
| Package | File_Archive |
| PHP Version | 5.0.3 |
| OS | Windows XP Home SP 2 |
| Roadmaps | (Not assigned) |
Comments
[2005-04-15 20:02 UTC] dmytton at php dot net
Description:
------------
I am using the example provided at http://poocl.la-grotte.org/tutorial.php to create a .zip archive from a directory of files/sub directories but I am getting the following error:
Fatal error: Cannot pass parameter 2 by reference in C:\Program Files\Apache Group\Apache2\htdocs\iono\includes\classes\iono\iono_downloads.php on line 265
The function is function toArchive($filename, &$innerWriter, $type = null, $stat = array(), $autoClose = true)
Changing this to
function toArchive($filename, $innerWriter, $type = null, $stat = array(), $autoClose = true)
Gives the following error:
Fatal error: Call to a member function newFile() on a non-object in C:\Program Files\Apache Group\Apache2\htdocs\iono\includes\classes\archive\File\Archive\Writer\Archive.php on line 70
Reproduce code:
---------------
$source = File_Archive::read('dir', 'dir');
File_Archive::toArchive('Zip', 'dir'.'zip', NULL);
Expected result:
----------------
The code should generate the .zip file
Actual result:
--------------
Fatal error: Cannot pass parameter 2 by reference in C:\Program Files\Apache Group\Apache2\htdocs\iono\includes\classes\iono\iono_downloads.php on line 265
[2005-04-15 20:05 UTC] dmytton at php dot net
This is using the latest 0.3 version of File_Archive and MIME.
[2005-04-15 20:42 UTC] lascauv4 at cti dot ecp dot fr
The tutorial provided on my website was not up to date. It has been changed to reflect the actual way to use the package
Your code should be
$source = File_Archive::read('dir', 'dir');
$source->extract(
File_Archive::toArchive('dir.zip',
File_Archive::toFiles()
)
);
Note that in your code, you have 'dir'.'zip' (which evaluates to 'dirzip') for the filename. I assume you mean 'dir.zip'. If you really want to generate a zip file named dirzip, you'll have to specify that you want a zip file (since looking at the extension won't help). The code would be:
$source = File_Archive::read('dir', 'dir');
$source->extract(
File_Archive::toArchive('dirzip',
File_Archive::toFiles(), 'Zip'
)
);