Php 消除错误4上传错误无文件/Don';T

Php 消除错误4上传错误无文件/Don';T,php,Php,我有一个允许上传文件的代码。当遇到ShowError4 UPLOAD\u ERR\u NO\u文件时,它会抛出一个错误处理程序功能错误和错误数组,下面的一些代码对此负责。我想要的是消除这个错误,并使它只是罚款时,没有文件上传。这意味着,即使没有上传的文件,代码仍然会继续处理。我该怎么做?这使我负担了好几天。请提供帮助,或将此信息分享给您认识的能够提供帮助的人。多谢各位 Index.php <?php // make a note of the current working

我有一个允许上传文件的代码。当遇到ShowError4 UPLOAD\u ERR\u NO\u文件时,它会抛出一个错误处理程序<代码>功能错误和
错误数组
,下面的一些代码对此负责。我想要的是消除这个错误,并使它只是罚款时,没有文件上传。这意味着,即使没有上传的文件,代码仍然会继续处理。我该怎么做?这使我负担了好几天。请提供帮助,或将此信息分享给您认识的能够提供帮助的人。多谢各位

Index.php

    <?php
    // make a note of the current working directory relative to root.
    $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);

    // make a note of the location of the upload handler
    $uploadHandler = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'processor.php';

    // set a max file size for the html upload form
    $max_file_size = 30000; // size in bytes

    // now echo the html page
    ?>

    <!DOCTYPE html>
    <html class="html">
     <head>
         <div class="container">
        <form action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post">

        SOME HTML CODE HERE 

        </form>
    </div>
    </head>
    </html>


请停止叫喊@geomagas我不是在喊。我甚至没有用感叹号。我只想强调一下我认为需要什么。谢谢你的帮助:)我刚刚编辑了问题的最后一部分,这样别人就不会认为我在喊:)
$errors = array(1 => 'php.ini max file size exceeded', 
                    2 => 'html form max file size exceeded', 
                    3 => 'file upload was only partial', 
                    4 => 'no file was attached');

    // check the upload form was actually submitted else print form
    isset($_POST['submit'])
        or error('the upload form is neaded', $uploadForm);

    // check for standard uploading errors
    ($_FILES[$fieldname]['error'] == 0)
        or error($errors[$_FILES[$fieldname]['error']], $uploadForm);

    @is_uploaded_file($_FILES[$fieldname]['tmp_name'])
        or error('not an HTTP upload', $uploadForm);

    @getimagesize($_FILES[$fieldname]['tmp_name'])
        or error('only image uploads are allowed', $uploadForm);

    $now = time();
    while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
    {
        $now++;
    }

    // now let's move the file to its final and allocate it with the new filename
    @move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)
        or error('receiving directory insuffiecient permission', $uploadForm);

    $name = $_POST['name'];
    $email = $_POST['email'];
    $office_id = $_POST['office_id'];

    $get_title = $_POST['title'];
    $title = strtoupper ($get_title);
    $namehere = "Super Story By " .$_POST['name'];
    $story =  $_POST['story'];
    header('Content-Type: image/jpeg');


    $upload = $uploadFilename;
    $im = imagecreatefromjpeg("bg.jpg");
    $img2 = imagecreatefromjpeg($upload);
    $black = imagecolorallocate($im, 0, 0, 0);
    $font = 'arialbi.ttf';
    $font2 = 'ariali.ttf';
    /*SOME MORE IMAGETTFTEXT CODE HERE*/
    imagedestroy($im);


    if (!empty($name) && !empty($email) && !empty($office_id) && !empty($title) && !empty($story)) {
        SOME QUERY HERE
    }


    function error($error, $location, $seconds = 5)
    {
        header("Refresh: $seconds; URL=\"$location\"");
        echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n".
        '"http://www.w3.org/TR/html4/strict.dtd">'."\n\n".
        '<html lang="en">'."\n".
        '   <head>'."\n".
        '       <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n".
        '       <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n".
        '   <title>Upload error</title>'."\n\n".
        '   </head>'."\n\n".
        '   <body>'."\n\n".
        '   <div id="Upload">'."\n\n".
        '       <h1>Upload failure</h1>'."\n\n".
        '       <p>An error has occured: '."\n\n".
        '       <span class="red">' . $error . '...</span>'."\n\n".
        '       The upload form is reloading</p>'."\n\n".
        '    </div>'."\n\n".
        '</html>';
        exit;
    } // end error handler