简体   繁体   English

_FILES['file1']['tmp_name'] 尝试在 php 中上传文件时为空

[英]_FILES['file1']['tmp_name'] is empty when tried to upload file in php

This problem occurs since few days ago.这个问题是几天前出现的。 This script is going well on localhost and on another online server.这个脚本在本地主机和另一个在线服务器上运行良好。 Hoping for response.希望得到回应。 I am unable to upload file on server.我无法在服务器上上传文件。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>

<div align="center">
    <div style="border:solid;">
<form action="test-upload.php" method="post" enctype="multipart/form-data" name="f1" id="f1" onSubmit="return cb1();">  
<div align="left" class="contentrequire"><strong>Attach Excel File (Call Detail/Description) </strong></div>
    <label>
       <input type="file" name="file1" id="file1" />
            </label>
            <label>
            <input type="submit" name="save" id="save" />
            </label>
        </form>
      </div>
</div>

 <?php 
    if(isset($_POST['save']))
    {

        echo print_r($_FILES);
        ?>
        <?php 


    //$target_path = $target_path ."testpankaj".".".$ext;


        echo $_FILES['file1']['tmp_name'];
    if(move_uploaded_file($_FILES['file1']['tmp_name'], "images/" . $_FILES["file1"]['name'])) {
           echo "The file ".  basename( $_FILES['file1']['name']). 
        " has been uploaded";
        } else{
            echo "There was an error uploading the file, please try again!";
        }
    }
    ?>  

if(isset($_POST['save']))

That's the issue, I believe.这就是问题所在,我相信。 The input doesn't appear to be defined.输入似乎没有定义。 Just add it, like this:只需添加它,就像这样:

<input type="submit" name="save" id="save" value="sent" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM