grilo Posted January 25, 2011 Share Posted January 25, 2011 Dear sirs. I´m new here and in php coding, after searching i found a php code that suits my needs. Creats a dir, and copy.zip file to new dir. - OK! Now i cant seem to be doing things right because i tried almost everything and can´t make it run. Here´s the code: <?php $newdirname = $_POST['Username']; if(file_exists($newdirname)) { print "&error_=Restaurante já existente.&"; }else{ $old = umask(0); mkdir($newdirname,0777); umask($old); echo"&error_=Obrigado - Restaurante adicionado com sucesso&"; $file = 'gdr_servidor.zip' ; $newfile = $newdirname."/".$file; chmod("gdr_servidor.zip", 0777); if (!copy($file, $newfile)) { echo "&error_=failed to copy $file"; //function extract_zip_file(){ // $zip = new ZipArchive; // $res = $zip->open('gdr_servidor.zip'); // This line // if ($res === TRUE) { // $zip->extractTo($newdirname); // This line // $zip->close(); // echo 'ok'; // This line // } else { // echo 'failed'; // This line // } //} $dir = opendir($newdirname); while(false !==($file=readdir($dir))){ if(strpos($file, '.zip',1)){ extractupdate($file); } } function extractupdate($file){ $zip=new ZipArchive; if($zip->open('temp/'.$file) == TRUE){ $update=rtrim($file, ".zip"); $zip->extractTo($newdirname); $zip->close(); echo "Extraction started."; } else { echo "Failed to start extraction."; } } function installupdate($update){ } } } ?> Can you assist me? I think it must be the chmod of the copied file to $newdirname... :-\ Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/225657-extracting-and-chmod/ Share on other sites More sharing options...
Maq Posted January 25, 2011 Share Posted January 25, 2011 (I placed tags around your code, please use them next time.) Quote Link to comment https://forums.phpfreaks.com/topic/225657-extracting-and-chmod/#findComment-1165147 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.