norwegianfellah Posted March 7, 2012 Share Posted March 7, 2012 Hello again, guys! I have a couple of questions that I hope anyone can answer. I am making a form that is storing the information in a database, and in this form I also want images to be uploaded. I want to make a function that allows the user to upload as many images as they would like to have in their ad on my website, and I also need something that can handle the upload process, and see how many images the user is trying to upload. Any easy solutions for this? I also have another question: As you can see on the example image underneath this text, I have a form with multiple inputs where the user is suppose to choose how many inputs they want to fill in themself. How should I store this information in the database, and how can I make a script that detects how many of the forms the user actually filled? I hope you guys understood what I was trying to say, and I thank you all anyways. Underneath you can see an image of my forms. Example image: Cheers, Marius Quote Link to comment https://forums.phpfreaks.com/topic/258447-multiple-image-upload-and-storing-a-specific-amount-of-values-controlled-by-user/ Share on other sites More sharing options...
blacknight Posted March 7, 2012 Share Posted March 7, 2012 uploading multiple files is easy on the field name for the files add [] for an array for multiple this is a function i use in my phpbb download section.. while(list($key,$value) = each($_FILES[upload_image][name])) { if(!empty($value)) { // this will check if any blank field is entered $filename = $value; // filename stores the value $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line $fanme = $dlid . "_" . $filename; //$target_path = "../dlfiles/screens/" . $fanme; $this->setMessage($target_path); $sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_url . "','1')"; $this->setMessage($sql); //* if (move_uploaded_file ( $_FILES ['upload_image'] ['tmp_name'], $target_path )) { $this->setMessage("The image " . $_FILES ['upload_image'] ['name'] . " has been uploaded"); $this->makethumb ( $_FILES ['upload_image'] ['name'], $target_path, $id2 ); $sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_path . "','1')"; $result = $db->sql_query ( $sql ); } else { $this->setMessage("Your uploaded was unseccessful"); exit (); } //*/ } } upload_image is ofcourse the name of my file field on my form i hope this helps.. Quote Link to comment https://forums.phpfreaks.com/topic/258447-multiple-image-upload-and-storing-a-specific-amount-of-values-controlled-by-user/#findComment-1324796 Share on other sites More sharing options...
norwegianfellah Posted March 8, 2012 Author Share Posted March 8, 2012 Thanks, that kinda helped out a bit.. Still don't understand how to create the array, and make the user able to choose how many images they want to upload themselves.. Also I wonder about the multiple inputs, where only the inputs with value is going to be put in the database Quote Link to comment https://forums.phpfreaks.com/topic/258447-multiple-image-upload-and-storing-a-specific-amount-of-values-controlled-by-user/#findComment-1325127 Share on other sites More sharing options...
blacknight Posted March 8, 2012 Share Posted March 8, 2012 set a base amount of fields on the page then have a dropdown with numbers from the base amount to the max you want and then that refreshes the page and makes more fields... if you look it up online you should be able to find how to do it ... and my function there ignores empty fields Quote Link to comment https://forums.phpfreaks.com/topic/258447-multiple-image-upload-and-storing-a-specific-amount-of-values-controlled-by-user/#findComment-1325230 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.