Query Master
Query Master

Reputation: 7097

Tar path issue in PHP

I am trying to create a TAR through exec in PHP, which will contain lots of folders. Each of the included folders represent a server path. Unfortunately my script to create this TAR is not working and I don't know what am I doing wrong. Linux is not my strongest point, so if anyone has an idea about what might be going wrong I would appreciate some insight.

CODE

 exec("tar czf ".DIR_PATH."/public/zip_folder/facebook_albums_1.tar.gz / ".DIR_PATH."public/zip_folder/facebook_albums_1");

CODE RESULT

var\chroot\home\content\78\10368378\html\domain\Facebook\public\zip_folder\facebook_albums_1

I WANT

zip_folder\facebook_albums_1

Upvotes: 0

Views: 131

Answers (1)

Marko D
Marko D

Reputation: 7576

Try doing

chdir(DIR_PATH . '/public/');

before exec, and then just change exec to

exec("tar czf zip_folder/facebook_albums_1.tar.gz zip_folder/facebook_albums_1");

Upvotes: 3

Related Questions