我不知道如果代碼是正確的,但最大文件大小不工作PHP OOP - 上傳表單後isset和文件大小這麼想的工作
,如果文件存在不澈與否,也許我錯誤地實現了 isset或代碼中有東西。
p.s.給我這個錯誤:
注意:未定義的變量:ecc ../ ecc中的內容。在線23
注意:未定義變量:fc in ecc ../ ecc。上線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();
?>
'$這個 - >內容= $內容; // $ content未定義局部變量 $ this-> fp = $ fp; // $ content not defined local variable' – Leri
我沒有得到一件事。錯誤信息非常明瞭。甚至給出行號。爲什麼它很難調試**你自己的代碼**? – Leri
是的,但不是這個問題..感謝 – starbuck