Ошибка при загрузке изображения
такую ошибку выдает хотя локальный сервер показывает что картинки и текст загружаются!
ЧТо не так?
файлы пчп после индекса помешены в папку lib!
1)Index.php
<?php
require_once "lib/uploadtext_class.php";
require_once "lib/uploadimage_class.php";
if ($_POST["upload"]) {
$upload_text = new UploadText();
$upload_image = new UploadImage();
$sucess_text = $upload_text->uploadFile($_FILES["text"]);
$sucess_image = $upload_image->uploadFile($_FILES["image"]);
}
?>
<html>
<head>
<title>Загрузка фалов</title>
</head>
<body>
<h1>Загрузка фалов</h1>
<?php
if ($_POST["upload"]) {
if ($success_text) echo "Текстовый файл успешно загружен";
else echo "Ошибка при загрузке Текстового файл";
echo "<br/>";
if ($success_image) echo "Изображение успешно загружено";
else echo "Ошибка при загрузке изображения";
}
?>
<form name="myform" action="index.php" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Изображение:</td>
<td>
<input type="file" name="image" />
</td>
</tr>
<tr>
<td>Текст:</td>
<td>
<input type="file" name="text" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="upload" value="Загрузить файлы" />
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
2) upload_class.php
abstract class Upload {
protected $dir;
protected $mime_types;
public function uploadFile($file) {
if (!$this->isSecurity($file)) return false;
$uploadfile = $this->dir."/".$file["name"];
return move_uploaded_file($file["tmp_name"], $uploadfile);
}
protected function isSecurity($file) {
$blacklist = array (".php",".phtml",".php3",".php4",".html",".htm ");
foreach ($blacklist as $item) {
if (preg_match("/$item\$/i", $file["name"])) return false;
}
$type = $file["type"];
for ($i = 0; $i< count($this->mime_types);$i++) {
if ($type == $this->mime_types[$i]) break;
if ($i + 1 == count($this->mime_types)) return false;
}
$size = $file["size"];
if ($size > 2048000) return false;
return true;
}
}
?>
3)uploadtext_class.php
<?php
require_once "upload_class.php";
class UploadText extends Upload{
protected $dir = "text";
protected $mime_types = array("text/plain");
}
?>
4)uploadimage_class
<?php
require_once "upload_class.php";
class UploadImage extends Upload{
protected $dir = "image";
protected $mime_types = array("image/png","image/jpeg","image/gif");
}
?>