moving files around

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robjime
Forum Commoner
Posts: 46
Joined: Sat Apr 03, 2004 12:26 pm
Location: the RO

moving files around

Post by robjime »

I have this zip file, and I want to extract it to a certain directory, say c:\myzippedfiles, So I found the unzip code but I don't know how to make it so that it will unzip into a directory other than the directory that the code executing the commands is in, so basically, I upload the zip file to c:\myzippedfiles but the code i have creates the files in my htdocs folder.

Thanx in advance.

Code: Select all

$zip = zip_open($zipfile);
		if ($zip) {
		  while ($zip_entry = zip_read($zip)) {
			$fp = fopen(zip_entry_name($zip_entry), "w");
			if (zip_entry_open($zip, $zip_entry, "r")) {
			  $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
			  fwrite($fp,"$buf");
			  zip_entry_close($zip_entry);
			  fclose($fp);
			}
		  }
		  zip_close($zip);
}
Post Reply