Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Defaulting a $_POST variable

New Here ,
Jan 31, 2010 Jan 31, 2010

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.

TOPICS
Server side applications
340
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 02, 2010 Feb 02, 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")
Translate
LEGEND ,
Feb 02, 2010 Feb 02, 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")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 02, 2010 Feb 02, 2010
LATEST

Thanks a lot david

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

Worked great.

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines