Skip to main content
Known Participant
January 31, 2010
Answered

Defaulting a $_POST variable

  • January 31, 2010
  • 2 replies
  • 342 views

I have an insert form where the first field has a browse button attached to it for upload a file.

Here is the code

<form action="<?php echo $editFormAction; ?>" form enctype="multipart/form-data" method="post" name="form1" id="form1">
      <table align="center">
        <tr valign="baseline">
          <td width="113" align="right" nowrap="nowrap">PictureLocation:</td>
          <td width="192"><input type="file" name="PictureLocation" value="" size="32" /></td>
           <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />

Now, when I run it, this correctly allows me to browse for a file and puts the file path into the empty field for me, but when I click on the submit button, the $_POST variable is null so it can't write to the data base.

I have tried to set the $_POST value to the $_FILE value like this

$_POST['PictureLocation'] = $_FILES["PictureLocation"]["name"];

but unfortunately this command is ignored, it still thinks $_POST is null

Any way around this.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer David_Powers

Why do you want to assign the value to the $_POST array? I presume this is because you're using an Insert Record server behavior that has something like this in the code:

GetSQLStringValue($_POST['PictureLocation'], "text")

The value doesn't need to be from the $_POST array. It can be whatever you like.

GetSQLStringValue($_FILES['PictureLocation']['name'], "text")

2 replies

David_Powers
David_PowersCorrect answer
Inspiring
February 2, 2010

Why do you want to assign the value to the $_POST array? I presume this is because you're using an Insert Record server behavior that has something like this in the code:

GetSQLStringValue($_POST['PictureLocation'], "text")

The value doesn't need to be from the $_POST array. It can be whatever you like.

GetSQLStringValue($_FILES['PictureLocation']['name'], "text")
harkusaAuthor
Known Participant
February 2, 2010

Thanks a lot david

I found the relevant SQL inserts and posted the value I wanted instead of the $POST.

Worked great.

Thanks