PHP & unrar problem, please help

Status
Not open for further replies.

dima1236

Active Member
95
2011
6
0
Hello Guys,
I am trying to make php script on unrar specific folder, this is the code i wrote so far :

PHP:
    $files=read_folder_directory($fullpath);
    foreach ($files as $key => $value)  {
        echo $key;
        echo "<br />";
        natsort($value);
        foreach($value as $file) {
            //echo $file;
             echo "$fullpath/$key/$file";
             echo "<br />";
                echo $string='unrar e -y'."$fullpath/$key/$file $fullpath/$key/";
                echo $exec = exec($string);
                echo "<br />";
             
        }
    }

now if i paste the $string output into the shell it does work and extract the filers, however the $exec returns "No files to extract"

any advice will be appreciated

Thanks
 
5 comments
I suspect it has to do with the quotes in this line

PHP:
echo $string='unrar e -y'."$fullpath/$key/$file $fullpath/$key/";

there is no space between the end of the unrar statement and the beginning of the file path.

PHP:
echo $string='unrar e -y'." $fullpath/$key/$file $fullpath/$key/";
Change it to that and see if it works.
 
Last edited:
i have made some change try this

PHP:
    $files=read_folder_directory($fullpath);
    foreach ($files as $key => $value)  {
        echo $key;
        echo "<br />";
        natsort($value);
        foreach($value as $file) {
            //echo $file;
             echo "'.$fullpath.'/'.$key.'/'.$file.'";
             echo "<br />";
                echo $string='unrar e -y "'.$fullpath.'/'.$key.'/'.$file.'" "'.$fullpath.'/'.$key.'/"';
                echo $exec = exec($string);
                echo "<br />";
             
        }
    }
 
Thanks all for the replies, it seems the PHP was correct lol, but the folder didn't have the correct permissions, sorry for that, and once again thank you for helping out.
 
Status
Not open for further replies.
Back
Top