dflow Posted February 26, 2011 Share Posted February 26, 2011 im doing smting basically wrong <form action="" method="post"> <?php $x=1; $images = $_GET['images']; for( $i=0; $i<$images; $i++ ) { echo '<input name="ID" type="hidden" value="1234" /> <br> <input name="ImageURL['.$i.']" type="file" value=""/><br><br>'; } ?> <input name="submit" type="submit" /> <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("international", $con); if (isset($_POST['submit'])) for( $i=0; $i<$images; $i++ ) { $query=mysql_query("INSERT INTO images (ID,ImageURL) VALUES ('$_POST[iD]','$_POST[imageURL]')"); exit; mysql_close($con); } ?></form> Link to comment https://forums.phpfreaks.com/topic/228963-mutliple-file-upload-and-insert-into-db-help/ Share on other sites More sharing options...
dflow Posted February 26, 2011 Author Share Posted February 26, 2011 a bit more code <form action="" method="post"> <?php $x=1; $images = $_GET['images']; for( $i=0; $i<$images; $i++ ) { echo '<input name="ID" type="hidden" value="1234" /> <br> <input name="ImageURL['.$i.']" type="file" value="" /><br><br>'; } ?> <input name="submit" type="submit" /> <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("international", $con); if (isset($_POST['submit'])) for( $i=0; $i<$images; $i++ ) { // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['ImageURL['.$i.']']['name']); $query=mysql_query("INSERT INTO images (ID,ImageURL) VALUES ('$_POST[iD]','$_FILES')"); exit; mysql_close($con); } var_dump($_POST); ?> </form> Link to comment https://forums.phpfreaks.com/topic/228963-mutliple-file-upload-and-insert-into-db-help/#findComment-1180156 Share on other sites More sharing options...
litebearer Posted February 27, 2011 Share Posted February 27, 2011 If you are seeking to upload files - your form is missing - enctype="multipart/form-data" http://www.tizag.com/phpT/fileupload.php Link to comment https://forums.phpfreaks.com/topic/228963-mutliple-file-upload-and-insert-into-db-help/#findComment-1180188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.