Jump to content

Problem with undefined index


jpratt

Recommended Posts

This is my code:

[code]
if($HTTP_POST_FILES['File_Name']['size'] > 0 && !file_exists("../owner/files/".$HTTP_POST_FILES['File_Name']['name']))
  { $FileIn  = $HTTP_POST_FILES['File_Name']['tmp_name'];
$FileOut = "../owner/files/".$HTTP_POST_FILES['File_Name']['name'];
move_uploaded_file($FileIn, $FileOut);


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO faqfile (File_FAQ_ID, File_Name) VALUES (%s, %s)",
                      GetSQLValueString($_POST['File_FAQ_ID'], "int"),
                      GetSQLValueString($HTTP_POST_FILES['File_Name']['name'], "text"));

  mysql_select_db($database_database, $database);
  $Result1 = mysql_query($insertSQL, $database) or die(mysql_error());
}
  $insertGoTo = "update.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
[/code]

I keep getting an error that 'File_name' is an undefined index. I have played with file uploads before but not like this. Anyone have an idea?
Link to comment
https://forums.phpfreaks.com/topic/28785-problem-with-undefined-index/
Share on other sites

Here is my form:

[code]
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
          <?php if($HTTP_POST_FILES['File_Name']['size'] > 0 && file_exists("../owner/files/".$HTTP_POST_FILES['File_Name']['name'])) { ?><p class="CaptionText">File name already in use, change file name or delete file off server!</p>
          <?php } ?>
          <table align="center">
            <tr valign="baseline">
              <td nowrap align="right">File Name:</td>
              <td>              <input name="File_Name" type="file" class="inputbox" id="File_Name"></td>
            </tr>
            <tr valign="baseline">
              <td colspan="2" align="center" nowrap><input name="Button" type="button" class="btn" onClick="MM_goToURL('parent','update.php?ID=<?php echo $_GET['ID']; ?>');return document.MM_returnValue" value="Cancel">                <input type="submit" class="btn" value="Insert record"></td>
            </tr>
          </table>
          <input type="hidden" name="File_FAQ_ID" value="<? echo $_GET['ID']; ?>">
          <input type="hidden" name="MM_insert" value="form1">
        </form>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.