nelquintin Posted April 8, 2012 Share Posted April 8, 2012 I can get files to upload to folder and add a new row for each in to a mysql db using the code below, how do I get all the filles in one row with multiple uploads //Check if the form was submitted. if(isset($_POST['uploadButton'])) { //Specify folder path where the file is going. $path = 'uploads/'; //Upload file one by one. foreach($_FILES['file']['name'] as $key => $val) { if($val != '') { $file_name = $_FILES['file']['name'][$key]; //Get file name. $file_tmp = $_FILES['file']['tmp_name'][$key]; //Get temporary file name. $file = $path . $file_name; mysql_query("INSERT INTO images (img1) VALUES('$file');") or trigger_error('Unable to INsert: ' . mysql_error()); //Move uploaded file if(move_uploaded_file($file_tmp, $file)) { echo 'File was succesfully uploaded to: ' . $file . '<br />'; } else { //Display error message if there was a problem uploading file. echo 'Error uploading file "' . $key . '."<br />'; } echo $target_path; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260568-writing-multiple-file-names-to-a-mysql-db-in-same-row/ Share on other sites More sharing options...
trq Posted April 8, 2012 Share Posted April 8, 2012 You shouldn't store them in one row. A new row for each image (how your currently doing it) is the best design. Quote Link to comment https://forums.phpfreaks.com/topic/260568-writing-multiple-file-names-to-a-mysql-db-in-same-row/#findComment-1335456 Share on other sites More sharing options...
nelquintin Posted April 9, 2012 Author Share Posted April 9, 2012 thanks Quote Link to comment https://forums.phpfreaks.com/topic/260568-writing-multiple-file-names-to-a-mysql-db-in-same-row/#findComment-1335736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.