【发布时间】:2015-07-15 13:56:51
【问题描述】:
我在 oop php 文件上传脚本上工作。很简单。但不起作用。问题是什么?我学习了如何使用 $_FILE,以及如何编写 oop 样式。
谢谢。
upload.php 是:
<?php
class upload{
public $src = "./upload/";
public $tmp;
public $filename;
public $type;
public $uploadfile;
public function startupload(){
$this -> filename = $_FILES["file"]["name"];
$this -> tmp = $_FILES["file"]["tmp_name"];
$this -> uploadfile = $src . basename($this -> name);
}
public function uploadfile(){
if(move_uploaded_file($this -> tmp, $this -> uploadFile)){
return true;
}
}
}
?>
index.php 是:
<?php
require_once('./lib/upload.php');
?>
<?php
if(isset($_POST['file'])){
$fileupload = new upload();
if($fileupload -> uploadfile()){
echo 'Fisierul a fost uploadat';
}
}
?>
<html>
<head></head>
<body>
<form align="center" enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
Select upload file: <input type="file" name="file" required="yes" />
<input type="submit" value="Trimite" />
<p>
</form>
</body>
</html>
我的修补有什么问题?
【问题讨论】: