[英]error showing when using opendir()
I was creating a wordpress plugin, now i got an error like 我正在创建一个wordpress插件,现在出现了类似的错误
Warning: opendir(http://localhost/wordpress/wp-content/uploads/): failed to open dir: not implemented in http://localhost/wordpress/wp-content/plugins/my-plugin/FlxZipArchive.php on line 37
Warning: readdir() expects parameter 1 to be resource, boolean given in http://localhost/wordpress/wp-content/plugins/my-plugin/FlxZipArchive.php on line 38
and these are the files 这些是文件
index.php index.php
<?php
$upload_dir = wp_upload_dir();
$folder_name = $upload_dir['baseurl'];
//Don't forget to remove the trailing slash
$the_folder =$foldername;
$zip_file_name = WP_CONTENT_DIR."/".'uploads.zip';
$za = new FlxZipArchive;
$res = $za->open($zip_file_name, ZipArchive::CREATE);
if($res === TRUE) {
$za->addDir($the_folder, basename($the_folder));
$za->close();
}
else
echo 'Could not create a zip archive';
?>
FlxZipArchive.php FlxZipArchive.php
<?
/**
* FlxZipArchive, Extends ZipArchiv.
* Add Dirs with Files and Subdirs.
*
* <code>
* $archive = new FlxZipArchive;
* // .....
* $archive->addDir( 'test/blub', 'blub' );
* </code>
*/
class FlxZipArchive extends ZipArchive {
/**
* Add a Dir with Files and Subdirs to the archive
*
* @param string $location Real Location
* @param string $name Name in Archive
* @author Nicolas Heimann
* @access private
**/
public function addDir($location, $name) {
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
} // EO addDir;
/**
* Add Files & Dirs to archive.
*
* @param string $location Real Location
* @param string $name Name in Archive
* @author Nicolas Heimann
* @access private
**/
private function addDirDo($location, $name) {
$name .= '/';
$location .= '/';
// Read all Files in Dir
$dir = opendir ($location);
while ($file = readdir($dir))
{
if ($file == '.' || $file == '..') continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile';
$this->$do($location . $file, $name . $file);
}
} // EO addDirDo();
}
?>
Every time when executing index.php it just creating a zip file with an empty folder in it and exiting 每次执行index.php时,它只会创建一个带有空文件夹的zip文件并退出
please someone help me to fix this error 请有人帮我解决这个错误
opendir()
is designed to open local directories ( file://
protocol) and since PHP 5.0.0 FTP ( ftp://
) opendir()
用于打开本地目录( file://
协议),并且自PHP 5.0.0起FTP( ftp://
)
It seems that you're trying to pass an URL ( http://
protocol), which is not valid param for opendir
似乎您正在尝试传递URL( http://
协议),该URL对opendir
无效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.