hoho32 Posted June 15, 2012 Share Posted June 15, 2012 Dear all friends I look hardly into a lot of topics and images, and its always ends up with not solved or a not good code that would suites my options. what I want is a code to upload multiple images and store them into a folder called upload and also the name of the folder will be inside a table in mysql called image_img. NOW I have done this code but only with uploading one image!. and thats the code i used if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO packages (idd, packageTitle, packageDescription, packageGraphic) VALUES (%s, %s, %s, %s)", GetSQLValueString($_SESSION['MM_adminId'], "text"), GetSQLValueString($_POST['packageTitle'], "text"), GetSQLValueString($_POST['packageDescription'], "text"), GetSQLValueString($_FILES['packageGraphic']['name'], "text")); mysql_select_db($database_dalilack, $dalilack); $Result1 = mysql_query($insertSQL, $dalilack) or die(mysql_error()); $target_path = "upload/".$_FILES['packageGraphic']['name']; move_uploaded_file($_FILES['packageGraphic']['tmp_name'],$target_path); $insertGoTo = "marketList.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } and just for your information this "idd" is to connect to each user personal information. so when uploading photos, it should be only connected for one user. so when display data. it will be like a dynamic table with his personal info and his images also. And that's kind of coding i couldn't solve and find in Google. So I am here hoping to be served and helped by you guys. Thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/264216-upload-multiple-images-to-mysql/ Share on other sites More sharing options...
hoho32 Posted July 11, 2012 Author Share Posted July 11, 2012 ok I have did some updates and add a code where you can upload more images <script type="text/javascript"> $(document).ready(function(){ $('#addFileInput').click(function(){ $('#packageGraphicDiv').html($('#packageGraphicDiv').html() + '<p><input type="file" name="packageGraphic[]" id="upload" value="" size="32" /></p>'); return false; }); }); </script> and then I have add $insertSQL = sprintf("INSERT INTO packages (idd, packageTitle, packageDescription, packageGraphic, packageGraphic2) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($_FILES['packageGraphic']['name'], "text"), GetSQLValueString($_FILES['packageGraphic2']['name'], "text")); and then these $target_path = "upload/".$_FILES['packageGraphic']['name']; move_uploaded_file($_FILES['packageGraphic']['tmp_name'],$target_path); $target_path = "upload/".$_FILES['packageGraphic2']['name2']; move_uploaded_file($_FILES['packageGraphic2']['tmp_name'],$target_path); and i am still getting an error! saying Column 'packageGraphic' cannot be null mysql_real_escape_string() expects parameter 1 to be string Undefined index: packageGraphic2 whats the problem? Quote Link to comment https://forums.phpfreaks.com/topic/264216-upload-multiple-images-to-mysql/#findComment-1360818 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.