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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.