Pekka
21st of January 2005 (Fri), 13:05
By common request here is zip support to upload page. It supports PhpConcept's Library Zip PclZip 2.3 which you have to download and install separately. Here's how:
1. Go to http://www.phpconcept.net/pclzip/index.en.php and download PclZip Release 2.3.
2. Unzip the package and copy file pcl*******b.php in your input folder.
3. In EDITOR_upload.php find this piece of code:
// GET DIRECTORY LISTING SORTED BY LAST MODIFIED
$dir = $upload_folder;
$filelist=array();
$directory = opendir($dir);
while ($file_name = readdir($directory)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".jpg" OR $ext == "jpeg" OR $ext == ".gif" OR $ext == ".png" OR $ext == ".bmp" OR $ext == ".tif" OR $ext == "tiff" OR $ext == ".psd") {
if (($file_name !=".") && ($file_name != "..") && (strtoupper($file_name) != ".HTPASSWD") && (strtoupper($file_name) != ".HTACCESS"))
{
$fileinfo = fopen ($dir . $file_name,"rb");
$stat = fstat($fileinfo);
$date = $stat[9];
$size = $stat[7];
if ($size!="") {
// means don't show folders
$filelist[] = array("filename" => $file_name, "date" => $date, "size" => $size);
}
fclose($fileinfo);
}
}
}
//ksort($filelist);
closedir ($directory);
REPLACE it with this code:
// GET DIRECTORY LISTING SORTED BY LAST MODIFIED
$dir = $upload_folder;
$filelist=array();
@include('pcl*******b.php');
if (class_exists("PclZip")) {
$directory_zip = opendir($dir);
while ($file_name = readdir($directory_zip)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".zip") {
$archive = new PclZip($dir . $file_name);
if (@$archive -> extract(PCLZIP_OPT_PATH, $dir) == TRUE) {
unlink($dir . $file_name);
}
}
}
closedir ($directory_zip);
}
$directory = opendir($dir);
while ($file_name = readdir($directory)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".jpg" OR $ext == "jpeg" OR $ext == ".gif" OR $ext == ".png" OR $ext == ".bmp" OR $ext == ".tif" OR $ext == "tiff" OR $ext == ".psd") {
if (($file_name !=".") && ($file_name != "..") && (strtoupper($file_name) != ".HTPASSWD") && (strtoupper($file_name) != ".HTACCESS"))
{
$fileinfo = fopen ($dir . $file_name,"rb");
$stat = fstat($fileinfo);
$date = $stat[9];
$size = $stat[7];
if ($size!="") {
// means don't show folders
$filelist[] = array("filename" => $file_name, "date" => $date, "size" => $size);
}
fclose($fileinfo);
}
}
}
//ksort($filelist);
closedir ($directory);
Now you have following functionality: When you place (by uploading via upload page "Step 1" or by ftp) a zip file (or files) in your EE's UPLOAD folder, next time you open/refresh upload page each zip package is extracted to UPLOAD folder. Each ZIP file is deleted automatically when extract is complete.
Use only zip files which have images in one level, i.e. no folder structures.
I've tested it only briefly, so if you have any problems let me know.
1. Go to http://www.phpconcept.net/pclzip/index.en.php and download PclZip Release 2.3.
2. Unzip the package and copy file pcl*******b.php in your input folder.
3. In EDITOR_upload.php find this piece of code:
// GET DIRECTORY LISTING SORTED BY LAST MODIFIED
$dir = $upload_folder;
$filelist=array();
$directory = opendir($dir);
while ($file_name = readdir($directory)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".jpg" OR $ext == "jpeg" OR $ext == ".gif" OR $ext == ".png" OR $ext == ".bmp" OR $ext == ".tif" OR $ext == "tiff" OR $ext == ".psd") {
if (($file_name !=".") && ($file_name != "..") && (strtoupper($file_name) != ".HTPASSWD") && (strtoupper($file_name) != ".HTACCESS"))
{
$fileinfo = fopen ($dir . $file_name,"rb");
$stat = fstat($fileinfo);
$date = $stat[9];
$size = $stat[7];
if ($size!="") {
// means don't show folders
$filelist[] = array("filename" => $file_name, "date" => $date, "size" => $size);
}
fclose($fileinfo);
}
}
}
//ksort($filelist);
closedir ($directory);
REPLACE it with this code:
// GET DIRECTORY LISTING SORTED BY LAST MODIFIED
$dir = $upload_folder;
$filelist=array();
@include('pcl*******b.php');
if (class_exists("PclZip")) {
$directory_zip = opendir($dir);
while ($file_name = readdir($directory_zip)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".zip") {
$archive = new PclZip($dir . $file_name);
if (@$archive -> extract(PCLZIP_OPT_PATH, $dir) == TRUE) {
unlink($dir . $file_name);
}
}
}
closedir ($directory_zip);
}
$directory = opendir($dir);
while ($file_name = readdir($directory)) {
$ext = strtolower(substr($file_name,-4));
if ($ext == ".jpg" OR $ext == "jpeg" OR $ext == ".gif" OR $ext == ".png" OR $ext == ".bmp" OR $ext == ".tif" OR $ext == "tiff" OR $ext == ".psd") {
if (($file_name !=".") && ($file_name != "..") && (strtoupper($file_name) != ".HTPASSWD") && (strtoupper($file_name) != ".HTACCESS"))
{
$fileinfo = fopen ($dir . $file_name,"rb");
$stat = fstat($fileinfo);
$date = $stat[9];
$size = $stat[7];
if ($size!="") {
// means don't show folders
$filelist[] = array("filename" => $file_name, "date" => $date, "size" => $size);
}
fclose($fileinfo);
}
}
}
//ksort($filelist);
closedir ($directory);
Now you have following functionality: When you place (by uploading via upload page "Step 1" or by ftp) a zip file (or files) in your EE's UPLOAD folder, next time you open/refresh upload page each zip package is extracted to UPLOAD folder. Each ZIP file is deleted automatically when extract is complete.
Use only zip files which have images in one level, i.e. no folder structures.
I've tested it only briefly, so if you have any problems let me know.