Hi I'm looking for the way to allow people to upload several images through an (existing) form. Let's say this is my form: <form id="form1" name="form1" method="post" action="result.php"> <label>Name: <input name="name" type="text" id="name" /> </label> <p> <label>Email: <input name="email" type="text" id="email" /> </label> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> Code (markup): And this is the code of the output page: <p>Name: <?PHP echo $_POST["name"];?></p> <p>Email: <?PHP echo $_POST["email"];?></p> <p>Show Pic 1: ?????</p> <p>Show Pic 2: ?????</p> <p>Show Pic 3: ?????</p> PHP: How can I add several fields to the form that allow people to browse their machine for a file and make sure the pics appear on the output page?
Your form will be something like this: <form action="result.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <label>Name: <input name="name" type="text" id="name" /> </label> <p> <label>Email: <input name="email" type="text" id="email" /> </label> </p> <p> <label>File 1: <input name="file1" type="file" id="file1"> </label> </p> <p> <label>File 2: <input name="file2" type="file" id="file2"> </label> </p> <p> <label>File 3: <input name="file3" type="file" id="file3"> </label> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> PHP: Output page will be something like: <?php $file1 = $_FILES['file1']['name']; $file2 = $_FILES['file2']['name']; $file3 = $_FILES['file3']['name']; move_uploaded_file($_FILES['file1']['tmp_name'],'files/'.$_FILES['file1']['name']); move_uploaded_file($_FILES['file2']['tmp_name'],'files/'.$_FILES['file2']['name']); move_uploaded_file($_FILES['file3']['tmp_name'],'files/'.$_FILES['file3']['name']); ?> <p>Name: <?PHP echo $_POST["name"];?></p> <p>Email: <?PHP echo $_POST["email"];?></p> <p>Show Pic 1: http://sitename.com/files/<?=$file1;?></p> <p>Show Pic 2: http://sitename.com/files/<?=$file2;?></p> <p>Show Pic 3: http://sitename.com/files/<?=$file3;?></p> PHP: I am skipping file verification (certain extensions,size,name, etc..). Peace,