错误的使用课程?

时间:2013-11-19 10:39:31

标签: php image file upload

我的图片上传过程中出现了疑似问题,我会告诉你:

<form action="check.php" method="POST">

    File: <input type="file" name="picture" value="" id="picture-field">
    <span class="error" id="file-error"></span>
    <br><br>
    <input type="submit" name="submit" value="send">

</form>

my check.php:

require 'ImageChecker.php';

if (!$_FILES)
    echo "exit because no FILES";

$imageChecker = new ImageChecker();

$imageError = "";

if(!$imageChecker->php_error($_FILES['picture']['error'])) {
    $imageError = "php error ocurred!";
    echo $imageError;

类ImageChecker.php:

class ImageChecker {

    // function for php-error-check
    public function php_error ($php_error) {
        if ($php_error === UPLOAD_ERR_OK) {
            return TRUE;
        } else {
            return FALSE;
        }    
    }

    // more functions..
}

每次,我上传图片,我得到:

exit because no FILES

php error ocurred!

为什么?我错了什么?真的需要你的帮助,谢谢和问候!!

1 个答案:

答案 0 :(得分:6)

在表格标签中,您需要提供        enctype =“multipart / form-data”

<form action="check.php" method="POST" enctype="multipart/form-data">

这在上传文件时非常重要