Jump to content

Recommended Posts

Hello. I am trying to create a script that presents you with a textbox where you enter the name of a .zip, .tgz, or .tar.gz file in that directory on your server. Then, it decompresses it one the server. Here is the script:

 

<?php 
$filename = $_GET['filename']; 
if (empty($filename)) 
{ 
?> 
<form action="" method="GET"> 
<input type="text" name="filename"> 
<input type="submit"> 
</form> 
<?php 
} 

else 
{ 
if (strpos($filename,".zip") >= 1) 
{ 
exec('unzip $filename',$ret); 
echo "Successful unzipping"; 
} 
elseif ((strpos($filename,".tgz") >= 1) || (strpos($filename,".tar.gz") >= 1)) 
{ 
exec('tar -xzf $filename',$ret); 
echo "Successful untargzing"; 
} 
else 
{ 
?> 
<form action="" method="GET"> 
<input type="text" name="filename"> 
<input type="submit"> 
</form> 
<?php 
} 
} 
?>

 

On the two exec lines, if I replace $filename with the actual name of a compressed file on my server, it will successfully decompress it, but if I leave it the way it is and enter that file's name in the textbox, it will not work. Why isn't it decompressing?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.