<?php $conn = mysqli_connect("localhost", "", "", ""); if (isset($_POST['submit'])) { $img[$i] = array(); $uploads_dir = "images/"; $i=1; foreach ($_FILES["image"]["error"] as $key => $error) { $name[$i] == ""; if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["image"]["tmp_name"][$key]; $img[$i] = $_FILES["image"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$img[$i]"); } $i++; } $sql = "INSERT INTO users(img1,img2,img3) VALUES('$img1','$img2','$img3')"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function addmore(num) { if(num==1) { document.getElementById('field2').style.display='block'; document.getElementById('ni1').style.display='block'; return false; } else if(num==2) { document.getElementById('field3').style.display='block'; return false; } } </script> </head> <body> <form enctype="multipart/form-data" name="" action="" method="post"> <div id="field1">Enter One Image :<input type="file" name="image[]" id="img1"/><a href="#" onclick="addmore(1)" id="ni1">addmore...</a></div> <div id="field2" style="display:none;">Enter Two Image :<input type="file" name="image[]" id="img2"/><a href="#" onclick="addmore(2);">add more...</a></div> <div id="field3" style="display:none;">Enter Three Image :<input type="file" name="image[]" id="img3"/><a href="#" onclick="addmore(3)" id="ni3">addmore...</a></div> <div id="field4" style="display:none">Enter Forth Image :<input type="file" name="image[]" id="img4"/><a href="#" onclick="addmore(4)" id="ni4">addmore...</a></div> <input type="submit" name="submit"/> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)