What's the effect of this?
fopen (' Php://output ', ' W ');
1.
Compressed file upload in Demo zip format
function Zqfileupload ($path, $proDir, $filename) {
Global $_configuration;//Root_sys get the root directory of the project
$dirpath =rtrim ($_configuration[' Root_sys '), '/'). $proDir;//The Path of the upload
if (!file_exists ($dirpath)) {
mkdir ($dirpath);
}
$dirname = $filename. ' _ '. Time (). Mt_rand (100);//Name of the directory
$dir = $dirpath. " /". $dirname;//directory to create directory and decompression to
$filepath = $dir. '/'. $filename;//uploaded file name
if (mkdir ($dir, 0777, True)) {
if (Move_uploaded_file ($path, $filepath)) {
$zip = new Ziparchive ();
$rs = $zip->open ($filepath);
if ($rs!== TRUE) {
Exit ("Decompression failed!") ");
}
$zip->extractto ($dir);
$zip->close ();
Unlink ($filepath);
return $proDir. ' /'. $dirname;//root path relative to the web
}
}
return false;
}
2. Recursively delete directories and files in directories
//delete directories (directories and files)
function Deletedir ($path) {
$path =rtrim ($path, '/');
if (file_exists ($path)) {
$handle = Opendir ($path);
while (FALSE!== $file =readdir ($handle)) {
if ($file = = '. ' | | $file = = ' ... ') {
Continue;
}
$pathFile = $path. ' /'. $file;
if (Is_dir ($pathFile)) {
Deletedir ($pathFile);
} else{
Unlink ($pathFile);
}
}
Closedir ($handle);
RmDir ($path);
}
}