Jump to content

Form + Upload


forumnz

Recommended Posts

Ok heres part of a page. It has a form and an I want the user to be able to upload a .doc or a .txt file by browing and clicking submit.

 

I honestly haven't got much of an idea on how to go further here. Please help.

 

Sam.

 

<form action="thanks_request.php" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="MM_validateForm('Name','','R','E-mail','','RisEmail','Phone','','RisNum');return document.MM_returnValue">
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="main">
                  <tr>
                    <td width="32%">Name*</td>
                    <td colspan="2"><label>
                      <input name="Name" type="text" id="Name" />
                    </label></td>
                  </tr>
                  <tr>
                    <td>E-mail*</td>
                    <td colspan="2"><input name="E-mail" type="text" id="E-mail" /></td>
                  </tr>
                  <tr>
                    <td>Business Name </td>
                    <td colspan="2"><input name="Business Name" type="text" id="Business Name" /></td>
                  </tr>
                  <tr>
                    <td>Phone*</td>
                    <td colspan="2"><input name="Phone" type="text" id="Phone" /></td>
                  </tr>
                  <tr>
                    <td valign="top" >What is your region?*</td>
                    <td colspan="2"><table width="100%" border="0">
                      <tr>
                        <td width="35%"><label>
                          <input name="radiobutton" type="radio" value="Northland Region" />
                        Northland</label></td>
                        <td width="65%"><label>
                        <input name="radiobutton" type="radio" value="Wairarapa Region" />
Wairarapa                        </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Auckland Region" />
Auckland                        </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Wellington Region" />
Wellington                        </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Waikato Region" />
Waikato                        </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Nelson Bays Region" />
Nelson Bays                       </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Bay of Plenty Region" />
Bay of Plenty                      </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Malborough Region" />
Malborough                        </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Gisborne Region" />
Gisborne                        </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="West Coast Region" />
West Coast                       </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Hawkes Bay Region" />
Hawkes Bay                       </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Canterbury Region" />
Canterbury                        </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Taranaki Region" />
Taranaki                        </label></td>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Timaru - Oamaru Region" />
Timaru - Oamaru                      </label></td>
                      </tr>
                      <tr>
                        <td><label>
                        <input name="radiobutton" type="radio" value="Wanganui Region" />
Wanganui                        </label></td>
                        <td><label>
                          <input name="radiobutton" type="radio" value="Otago Region" />
Otago                        </label></td>
                      </tr>
                      <tr>
                        <td><input name="radiobutton" type="radio" value="Manawatu Region" />
                          Manawatu</td>
                        <td><input name="radiobutton" type="radio" value="Southland Region" />
                          Southland</td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"> </td>
                  </tr>
                  <tr>
                    <td valign="top">If you have a design brief (RFP), please upload it here </td>
                    <td width="41%"><label>
                      <input type="file" name="file" />
                    </label></td>
                    <td width="27%"> See our <a href="rfp.php" class="main">free resource</a> on how to write an RFP</td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"> </td>
                  </tr>
                  <tr>
                    <td colspan="3">If you do not know what you want, please use the questions below </td>
                    </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"> </td>
                  </tr>
                  <tr>
                    <td>What is the purpose of your business? </td>
                    <td colspan="2"><textarea name="Business Purpose" id="Business Purpose"></textarea></td>
                  </tr>
                  <tr>
                    <td>Who is your target market? </td>
                    <td colspan="2"><textarea name="Target Market" id="Target Market"></textarea></td>
                  </tr>
                  <tr>
                    <td>What is the main distribution method? </td>
                    <td colspan="2"><textarea name="Distribution Method" id="Distribution Method"></textarea></td>
                  </tr>
                  <tr>
                    <td>Who are your competition? </td>
                    <td colspan="2"><textarea name="Competition" id="Competition"></textarea></td>
                  </tr>
                  <tr>
                    <td>If you have a budget, what is it?  </td>
                    <td colspan="2"><textarea name="Budget" id="Budget"></textarea></td>
                  </tr>
                  <tr>
                    <td>Is this the maximum budget? </td>
                    <td colspan="2"><input name="Budget Max Yes" type="radio" value="radiobutton" />
                      Yes
                      <br />
                      <input name="Budget Max No" type="radio" value="radiobutton" />
                      No</td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"> </td>
                  </tr>
                  <tr>
                    <td>When do you want this project completed? </td>
                    <td colspan="2"><input name="Completed Now" type="radio" value="radiobutton" />
                      Now<br />
                      <input name="Completed in a few months" type="radio" value="radiobutton" /> 
                      Within a few months<br />
                      <input name="Completion Unknown" type="radio" value="radiobutton" />
                      Not sure just yet </td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"> </td>
                  </tr>
                  <tr>
                    <td>I agree to the terms and conditions. <a href="terms.php" class="main">T & C.</a> </td>
                    <td colspan="2"><label>
                      <input name="Terms and Conditions AGREED." type="checkbox" id="Terms and Conditions AGREED." value="checkbox" checked="checked" />
                    </label></td>
                  </tr>
                  <tr>
                    <td> </td>
                    <td colspan="2"><label>
                      <input type="submit" name="Submit" value="Send!" />
                    </label></td>
                  </tr>
                </table>
                  </form>

Link to comment
https://forums.phpfreaks.com/topic/54031-form-upload/
Share on other sites

I have found this code on my computer. It was written some time ago now, by me and my uncle, so I'm not too sure if it works / what you are looking for. You have to set the permissions to the folder to "777" on your ftp.

<?php
//set where you want to store files
//in this example we keep file in folder upload 
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$HTTP_POST_FILES['ufile']['name']; // change "upload/" to the location on the server
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "<h1>Successful</h1><BR/>"; 

//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "<strong>File Name :</strong>".$HTTP_POST_FILES['ufile']['name']."<BR/>"; 
echo "<strong>File Size :</strong>".$HTTP_POST_FILES['ufile']['size']."<BR/>"; 
echo "<strong>File Type :</strong>".$HTTP_POST_FILES['ufile']['type']."<BR/>"; 
}
else
{
echo "Error";
}
}
?>

 

Let me know how it goes

From

Cal

Link to comment
https://forums.phpfreaks.com/topic/54031-form-upload/#findComment-267138
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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