PHP使$\u文件为空

PHP使$\u文件为空,php,ajax,apache,Php,Ajax,Apache,我有一个表单,可以发布带或不带图像的文本。 当我上传带有图像的文本后,我只想上传文本 没有任何图像,但是$\u文件仍然充满了我上传的最后一张图像。 因此,我的问题是如何在上传图像后将$\u文件清空。 我已经试过了: unset($_FILES['file'][0]) but i cant get it empty. <?php session_start(); include_once("conf/config.ph

我有一个表单,可以发布带或不带图像的文本。 当我上传带有图像的文本后,我只想上传文本 没有任何图像,但是
$\u文件
仍然充满了我上传的最后一张图像。 因此,我的问题是如何在上传图像后将
$\u文件
清空。
我已经试过了:

  unset($_FILES['file'][0])

 but i cant get it empty.



           <?php   
       session_start();

        include_once("conf/config.php");
        include_once("twitteroauth/twitteroauth.php");
        echo '<script> function clearform(){ document.getElementById("fileupl").value=" "; }<script>';
       $name = $_POST['txt1'];
       $myfile = $_FILES["fileup"]["name"];
       $connection = new TwitterOAuth($consumer_key,     
       $consumer_secret,$access_token,$accesstoken_secret);
       //print_r($_POST);
       var_dump($_FILES);
       $image = "";
       $errors = "";

     if(isset($_FILES["fileup"])){

        //echo 'jajajajajaja';
        $account = $connection->get('account/verify_credentials');
        /* KIJK OF ER EEN FOUT IS OPGETREDEN */
        if($_FILES["fileup"]["error"] > 0){ 
                    echo "Error occured ".$_FILES["fileup"]["error"];  
        }
        /* GEEN FOUT */ 
        $e = $_FILES['fileup']['tmp_name'];
        /* CONTROLEER PHP'S INGEBOUWDE ERROR CHECK VOOR UPLOADEN. */
        if($_FILES['fileup']['error']) echo $errors[$_FILES['file']['error']]; 
        $image = $e;
        /* ALS ER GEEN FOTO GESELECTEERD IS, POST ALLEEN DE TEKST */     
        if($image === "") {
            $paramss = array('status'  => $name);
            $post= $connection->post('statuses/update',$paramss);  
            exit();
        } 
        /* ANDERS TEKST MET FOTO */      
        $handle = fopen($image,"r");
        $image     = fread($handle,filesize($image));
        fclose($handle);
        $params = array(
            'media[]' => "{$image};type={$_FILES['file']['type']};filename={$_FILES['file']['name']}",
            'status'  => $_POST['txt1'],
            true, // use auth
            true  // multipart
        );

 $DataProcessed = $connection->post('statuses/update_with_media',$params, true);


if (isset($DataProcessed) && $DataProcessed){

$_FILES = array();        $_FILES['file']['name'] = null;
        $_FILES['file']['tmp_name'] = null;
        $_FILES['file']['error'] = null;
        $_FILES['file']['size'] = null;
        echo "data processed";
        var_dump($_FILES);  
$_POST = array(); // lets pretend nothing was posted        //




// Define the folder to clean
// (keep trailing slashes)
$captchaFolder  = 'd:/windows/temp/';

// Filetypes to check (you can also use *.*)
$fileTypes      = '*.*';

// Here you can define after how many
// minutes the files should get deleted
$expire_time    = 1; 

// Find all files of the given file type
foreach (glob($captchaFolder . $fileTypes) as $Filename) {

    // Read file creation time
    $FileCreationTime = filectime($Filename);

    // Calculate file age in seconds
    $FileAge = time() - $FileCreationTime; 

    // Is the file older than the given time span?
    if ($FileAge > ($expire_time * 6)){

        // Now do something with the olders files...

        print "The file $Filename is older than $expire_time minutes\n";

        // For example deleting files:
        unlink($Filename);
        }

        `enter code here`}

        exit();
       } 
       } 


       ?>
       and i use this in my form
 onsubmit="setTimeout(function(){clearform()},3000);"
unset($\u文件['file'][0])
但是我不能把它弄空。
我假设你是这样的
现在,您可以在提交表单后在Post.php中获得值

有关更多说明,请参见:

您是否尝试过“$\u FILES['file'][0]=array();”使用is_数组函数我将向您推荐未工作的图像。我的表单已连续提交两次。我不确定您是否理解我的意思,但我不希望发布的值我希望上传图像后数组$文件为空。我尝试了以下$_文件['file'][0]=array();在上传图片的那一行之后,但是现在没有上传图片,所以在上传之前它被清除了,我想在上传之后它被清除。这是执行上传的行:$post=$connection->post('status/update_with_media',$params,true);印刷(邮政);在这一行之后,我有$_FILES['file'][0]=array();好的,suchit试过了,但没有清除这是我试过的:
$DataProcessed=$connection->post('status/update_with_media',$params,true);如果(isset($DataProcessed)&&&$DataProcessed){//header(“Location:indexx.php”);exit();}
正常,它现在正在工作,但问题仍然存在,我确保清空$_FILES数组,但第一条推文中的图像也会与第二条推文一起上载,因此是否还有其他地方存储此数组或其他内容;DataProcessingFunction()表示为您插入记录的方法。哦,好的,我错了,我去试试。好的,我试过了,但没有清除这是我试过的:$DataProcessing=$connection->post('statuses/update\u with\u media',$params,true);如果(isset($DataProcessed)&&&$DataProcessed){header(“Location:indexx.php”);exit();}是index.php文件的拼写。
I have assume that youe form like this 
 <form id="frmTest" name="frmTest" action="post.php" method="post" enctype="multipart/form-data">
   <input type="test" id="imgName" name="imgName">
   <input type="file" id="uploadImg" name="uploadImg">
   <input type="submit" value="submit" name="btnsub" id="btnsub">
</form>

Now you can get value in Post.php after submit form
 <?php
       echo "<pre>";print_r($_POST); //it show image name if you add other wise show null
       echo "<pre>";print_r($_FILES);//it show upload image if you can upload otherwise show null
 ?>   
if (isset($_FILE)){
 $DataProcessed = DataProcessingFunction();
}

if (isset($DataProcessed) && $DataProcessed){
  header("Location: /path/to/form/page.php");
  exit();
}