不在if语句中获取变量。

时间:2014-04-24 01:34:15

标签: php mysql

if($_FILES['fileField']['tmp_name']!= "") {

$newname="$fid.jpg";
echo $newname;
move_uploaded_file($_FILES['fileField']['tmp_name'],"images/covers/$newname");
    }

我正在尝试更新图像但是id变量未被识别

  

注意:未定义的变量:D中的targetID:\ shares \ Student \ web \ soft20171 \ N0431485 \ Film on Time - 更新了\ update_movie.php第125行   名为.jpg

     

警告:move_uploaded_file(images / covers /'

     

注意:未定义的变量: D:\ shares \ Student \ web \ soft20171 \ N0431485中的targetID \ Film on Time - 更新\ update_movie.php 在行 125
'.jpg):无法打开流:D:\ shares \ Student \ web \ soft20171 \ N0431485中的参数无效\电影时间 - 第64行更新\ update_movie.php

     

警告:move_uploaded_file():无法将'C:\ WINDOWS \ Temp \ php372.tmp'移动到'images / covers /'

     

注意:未定义的变量: D:\ shares \ Student \ web \ soft20171 \ N0431485中的targetID \ Film on Time - 更新\ update_movie.php > 左'.jpg'

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我将为您提供一份工作样本,我已经帮助了另一个人,这将纠正您的问题:

<?php
if(isset($_FILES['userfile'])){

$uploaddir = '/var/www/test/uploads/'; // path to be uploaded
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
        if (!file_exists($uploaddir)) {
            mkdir($uploadDir, 0777, true);
        }

echo "<p>";

// Error Checking Extended
    if($_FILES['userfile']['error'] == 2) {
    echo "You've exceeded the maximum file upload size of 512kb.";
    return false;
    }

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
  echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Upload failed";
}

echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
} else {
?>
<form enctype="multipart/form-data" action="" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="512000" />
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
<?php
}
?>