Now I tried to use your script: $_REQUEST['image'] is = '../images/2002/09/jpg/ls006022_pettersson_johan.jpg';
<? Header('Content-Type: application/x-gzip'); $command = 'tar -cf - ../images/' . $_REQUEST['image'] . ' | gzip -cf'; system( $command ); ?> It opens the download dialog again and lets me download the archive, but it's named download.gz (How can I change it to ls006022_pettersson_johan.gz?) And if I open it with winrar it says, the content is named 'download' Size is about 1600000 bytes, seems to be correct. when I try to extract the files there pops up an error message which says: Unexpected end of archive. Have you got a sollution on that? Grettings Sascha > > Hi Erwin, > > Hi Sascha, > > > > > I tried to put the Header at top of the page. After this it opens an > > download window > > in the browser. But the download seems to be damaged. What can I do > > about this? > > > > My commandline looks like this: > > > > <? > > Header( 'Content-Type: application/x-tar' ); > > $command = 'tar -c '.$arrResult['name'].'.tgz > > ../images/'.$arrResult['image']; > > system($command); > > ?> > > Ah...well...you are creating a tar file, named $arrResult['name'], with > $arrResult['image'] as contents. > You're creating this .tar file with the extension .tar.gz...which is wrong, > because that has to be .tar > > After that you are using the system() function to print the output to a > user...the output from the tar -c command will NOT be a tarred archive, but > probably will return nothing... > > Try the following: > > <? > Header( 'Content-Type: application/x-gzip); // CHANGED!!! > $command = 'tar -cf - ../images/' . $arrResult['image'] . ' | gzip -cf' > system( $command ); > ?> > > Step by step: > tar -cf - <filename> | gzip -cf > > The first part: tar -cf - <filename>. With the -c argument, you'll create a > new archive. The -f option specifies the output. In this case, the output is > '-', which is STDOUT. > The second part: gzip -cf. The -c options will print the output of the gzip > command to STDOUT, the -f option will force the output > > Between those two commands is a pipe (|). This character pipes the output > from the first program to the second, so the output of the tar command will > be given to gzip, which will create a .tar.gz ( or .tgz) file for you! > > Also, if the arrResult['image'] file is given by a user, take a good look at > http://www.php.net/escapeshellarg. If you get this value from a database, > which is secure (e.g. only contains items which you inserted), then you > don't have to worry about that... > > I hope this helps? > > Greetz, > Erwin > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php