tags:

views:

27

answers:

3
<body>
    <form method="post" action="xx.php" >
        Enter Title of the Post<INPUT type="text" name="title">
    <br/>
    Enter Description
    <textarea rows="10" cols="50" wrap="physical" name="post">
    </textarea><br/>
    <input type="Submit" value="Post">

    <br/><br/>


  <form enctype="multipart/form-data" action="xx.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
    Choose a file to upload: <input name="uploaded_file" type="file" />
    <input type="submit" value="Upload" />
  </form>

How Do I get the user to write the text and browse the image, only after which pressing a single button would both upload the text and the file?

A: 

You can't submit two forms with the same button. You'll need to combine the two fields into a single form.

Johannes Gorset
A: 

You can move the file input to the first <form> (which btw, you haven't closed) and use javascript to check if text has been entered and file has been selected.

Amarghosh
A: 

Don't nest your form tags (It's invalid HTML). You can place all the inputs in one form so they are posted together.

e.g.

<form enctype="multipart/form-data" action="xx.php" method="post"> 
  Enter Title of the Post<INPUT type="text" name="title"> 
  <br/> 
  Enter Description 
  <textarea rows="10" cols="50" wrap="physical" name="post"> 
  </textarea>
  <br/>
  <br/>
  <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> 
  Choose a file to upload: <input name="uploaded_file" type="file" /> 
  <input type="submit" value="Upload" /> 
</form>

Oh, as a sidenote, you may not want to use a name like "post" in your input control.

Andre Artus