I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have:
tar -cf tarname.tar -C /www/path/path/file1.txt /
If you don't know how many components are in the path, you could try this:
DIR_TO_PACK=/www/path/ cd $DIR_TO_PACK/.. tar -cf tarname.tar $(basename $DIR_TO_PACK)