Jump to content

Extracting and CHMOD


grilo

Recommended Posts

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!!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/225657-extracting-and-chmod/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.