我不知道代码是否正确,但 MAX FILE SIZE 不起作用
并且不要检查文件是否存在,也许我错误地实现了 isset 或者代码中有什么东西。
ps给我这个错误:
注意:未定义变量:ecc../ecc 中的内容。在第 23 行
注意:未定义变量:ecc../ecc 中的 fp。在第 24 行
这是代码:
<?php
interface ICheckImage {
public function checkImage();
}
abstract class ACheckImage implements ICheckImage {
public $fileName;
public $tmpName;
public $filesSize;
public $fileType;
public $fp;
public $conent;
protected $mysqli;
public function __construct(){
$this->fileName = $_FILES['userfile']['name'];
$this->tmpName = $_FILES['userfile']['tmp_name'];
$this->filesSize = $_FILES['userfile']['size'];
$this->fileType = $_FILES['userfile']['type'];
$this->content = $content;
$this->fp = $fp;
$this->mysqli = new mysqli('localhost','root','root','test');
}
}
class Check extends ACheckImage {
public function checkImage(){
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0){
$this->fileName = $_FILES['userfile']['name'];
$this->tmpName = $_FILES['userfile']['tmp_name'];
$this->filesSize = $_FILES['userfile']['size'];
$this->fileType = $_FILES['userfile']['type'];
$this->fp = fopen($this->tmpName, 'r');
$this->content = fread($this->fp, filesize($this->tmpName));
$this->content = addslashes($this->content);
fclose($this->fp);
if(!get_magic_quotes_gpc()){
$this->fileName = addslashes($this->fileName);
}
if ($this->mysqli->query("INSERT INTO upload_images (name, size, type, content ) ".
"VALUES ('$this->fileName', '$this->filesSize', '$this->fileType', '$this->content')")){
echo "Upload avvenuto  ";
}else{
echo "Errore  " . $this->mysqli->error;
}
}
}
}
$form = new Check();
$form->checkImage();
?>