Hi Team,

I am new to drupal as well as php. I learnt few syntax for creating Zip file out of the files existing in a directory using php.

Using the same , I tried creating a Zip file with the '/site/default/files' directory in drupal folders. I see that when I execute the respective php code, I am not able to see the zip file being created.

Instead when I execute the same php code by creating a new project under WAMP, i am able to create a zip file.

If it is a folder, file permission issue, I have provided complete read , write, xecute rights for files directory.Even then i am not able to create a Zip file, please help me to solve this issue

Following is the code snippet

<?php
/*
* PHP ZIP - Create a ZIP archive
*/
error_reporting(E_ALL);
ini_set("display_errors", "On");
clearstatcache();
$dir = "D:/wamp/www/cmp/sites/all/ArchiveTry";
$dh  = opendir($dir);
clearstatcache();
$zip = new ZipArchive;
global $base_path;
$base_path='/sites/';
$file='';
while (false !== ($filename = readdir($dh))) {
	if(filetype(($dir.'/'.$filename))!='dir'){
	print_r($filename);
	print_r('<br />');
	$zip->open($dir.'/zippednew.zip',  ZIPARCHIVE::CREATE);
	$zip->addFile($filename);
	$zip->close();
	$files[] = $filename;
	}
}
clearstatcache();
?>

from the above code, I tried giving the path as "/sites/default/modules" also as mentioned above, none of the case helped me in creating a zip file. Also it would be great to know , how to define relative paths instead of defining absolute paths as above.

Does this has anything to do with .htaccess files ?

regards
Kalaiyappan V

Comments

kalaiyappan1389’s picture

Issue summary: View changes
kalaiyappan1389’s picture

Issue summary: View changes

Version: 7.3 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.