Send form data to iframe via mail [file upload]

UGH.

Hey.

I have a form. I would like to know how / if I can submit this form to an iFrame that has a page that will handle uploading / naming files.

If I try even something as simple as an input / text message to a form, nothing happens (the handler is set to echo the $ _POST value). I tried to set the name iframe / id et. and others and setting the target of the form to the appropriate name / id iframe. When I hit submit, the iframe just sits there like a dummy. WTF am I doing wrong?

thank.

<form action="/clients/testAddTrans/<?=$clientID?>" id="reportEdit" class="EditName" method="POST" target="transFrame">
    <div class="inputDiv">
        <span class="inputLabel">Description:</span>
        <span class="textInput">
            <input type="text" id="transDesc" name="transDesc" value="" size="40" class=""/>
        </span>
    </div>
    <div class="inputDiv">
        <span class="inputLabel">Date:</span>
        <span class="textInput">
            <input type="text" id="date" name="transDate" value="" size="40" class=""/>
        </span>
    </div>
    <div class="inputDiv">
        <span class="inputLabel">File:</span>
        <span class="textInput">
            <input type="file" id="file" name="transFile" value="" size="40" class=""/>
        </span>
    </div>
    <input name="name_id" type="hidden" value="<?=$itemid?>" />
    <input type="submit" value="Submit" name="submit"/>
    <input type="button" class="secondaryAction" onclick="hideOverDiv()" value="Close"/>
    <div id="overDivNotice" class="overDivNotice" style="display:none"></div>
    <iframe action="/clients/testAddTrans/<?=$clid?>" id="transFrame" name="transFrame" style=""></iframe>
</form>

      

Generated html via firebug:

    <div class="content" id="overDivContent"><div class="inputDivContainer">
  <fieldset class="inputOverDiv" id="tfa_Names">
 <legend><b>Add Transmittal:</b></legend>
  <div class="data"><form target="transFrame" method="POST" class="EditName" id="reportEdit" action="/clients/testAddTrans/fsdf1556"><div class="inputDiv"><span class="inputLabel">Description:</span><span class="textInput"><input type="text" class="" size="40" value="" name="transDesc" id="transDesc"/></span></div><div class="inputDiv"><span class="inputLabel">Date:</span><span class="textInput"><input type="text" class="" size="40" value="" name="transDate" id="date"/></span></div><div class="inputDiv"><span class="inputLabel">File:</span><span class="textInput"><input type="file" class="" size="40" value="" name="transFile" id="file"/></span></div><input type="hidden" value="121" name="name_id"/>
  </form><br/>
  <div align="center" class="actions" id="overDivActions">
   <input type="submit" name="submit" value="Submit"/>
   <input type="button" value="Close" onclick="hideOverDiv()" class="secondaryAction"/>
  </div>
  <div style="display: none;" class="overDivNotice" id="overDivNotice">
  </div></div>


  <iframe style="" name="transFrame" id="transFrame">tyh</iframe>
  </fieldset>
  </div></div>

      

I don't know why it is putting the tag </form>

where it is .. It should be after the iframe, but whatever. Does it even matter? Is the iframe supposed to be inside the form?

+2


source to share


5 answers


Nice, I was wrong. I found the problem. First use html to write html; The code below works:

for 'testSubmitiFrame.html':

    <form target="transFrame" method="POST" class="EditName" id="reportEdit" action="testSubmitiFrame.php">
<div class="content" id="overDivContent">
    <div class="inputDivContainer">
        <fieldset class="inputOverDiv" id="tfa_Names">
        <legend><b>Add Transmittal:</b></legend>
        <div class="data">
            <div class="inputDiv">
                <span class="inputLabel">Description:</span>
                <span class="textInput"><input type="text" class="" size="40" value="" name="transDesc" id="transDesc"/></span>
            </div>
            <div class="inputDiv">
                <span class="inputLabel">Date:</span>
                <span class="textInput"><input type="text" class="" size="40" value="" name="transDate" id="date"/></span>
            </div>
            <div class="inputDiv">
                <span class="inputLabel">File:</span>
                <span class="textInput"><input type="file" class="" size="40" value="" name="transFile" id="file"/></span>
            </div>
            <input type="hidden" value="121" name="name_id"/>
            <br/>
            <div align="center" class="actions" id="overDivActions">
                <input type="submit" name="submit" value="Submit"/>
                <input type="button" value="Close" onclick="hideOverDiv()" class="secondaryAction"/>
            </div>
            <div style="display: none;" class="overDivNotice" id="overDivNotice"></div>
        </div>
        </fieldset>
    </div>
</div>
</form>
<iframe style="" name="transFrame" id="transFrame">tyh</iframe>

      



for 'testSubmitiFrame.php':

<?php
var_dump($_POST);
?>

      

Your problem is html syntax. It works.

+6


source


Apparently the div tag or silly field labels that were misplaced were getting in the way. I really should start checking my code before bothering you with nice people.



Thank you anyway.

+1


source


Your logic seems to be valid, can you customize the test page?

0


source


This page will do what you want, so you can browse it and see what may be different from what you are already doing: http://www.anyexample.com/programming/php/php_ajax_example__asynchronous_file_upload.xml

Is the action in the html php file that will be processed?

0


source


I think because of these two lines:

echo "</div>";
echo "</div><br>

      

You close <div>

without opening tags. This forces Firefox to close <form>

early - the submit button is not inside your form, so it doesn't work.

The position of the iframe inside or outside the form doesn't matter - just make sure the rest of the HTML is valid and should work.

0


source







All Articles