beermaker74 Posted September 22, 2006 Share Posted September 22, 2006 Hello all,this is my first post. I am a complete newbie at this. I have this problem that I am sure is easy to fix. I need a user to be able to upload 20 images to my mysql database from the web. I have read that this is not a good idea because of server load etc. This is not an issue for me. I need to input about 30 text fields and 20 images in blob. I can input one image and one description with this script//<?phpif ($action == "upload") {// ok, let's get the uploaded data and insert it into the db nowinclude "open_db.inc";if (isset($binFile) && $binFile != "none") {$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));$strDescription = addslashes(nl2br($txtDescription));$sql = "INSERT INTO binary_data ";$sql .= "(description, bin_data, filename, filesize, filetype) ";$sql .= "VALUES ('$strDescription', '$data', ";$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";$result = mysql_query($sql, $db);echo "Thank you. The new file was successfully added to our database.<br><br>";echo "<a href='main.php'>Continue</a>";}mysql_close();} else {?><HTML><style type="text/css"><!--body {background-color: #FFFFCC;}--></style><title>Sql image upload form works</title><BODY><FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data"><div align="center"><INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000"><INPUT TYPE="hidden" NAME="action" VALUE="upload">Welcome to the image upload page. Just upload away </div><TABLE BORDER="1" align="center"><TR><TD>Description: </TD><TD><textarea name="txtDescription" rows="5" cols="50"></textarea></TD></TR><TR><TD>File: </TD><TD><INPUT TYPE="file" NAME="binFile"></TD></TR><TR><TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD></TR></TABLE></FORM></BODY></HTML><?php}?>can I adjust this script to have the 20 image fields and 20 descriptions that I need. I just can't figure out what I need to change. If there is some other script that I should use then let me know. I am trying my best to learn this. I thank you for your time Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted September 22, 2006 Share Posted September 22, 2006 Here is a Basic layout of how you could give the option of multi file uploads[code=php:0]<? if ($b == '') {$b = 1;} if ($b > 20) {$b = 20;} echo "<form method='POST' enctype='multipart/form-data'>"; echo "Enter Number of Files to Upload at once (Max: 20)<br>"; echo "<input align=center type='text' size=5 maxlength=2 name='b' value=".$b.">"; echo "<input type='hidden' name='TRN' value=".$TRN.">"; echo "<input type='hidden' name='User_Name' value=".$User_Name.">"; echo "<input type='hidden' name='TP' value=".$TP.">"; echo "<input type=hidden name=FNID value=".$FNID.">"; echo "<input type='Submit' name=cmd value='Reload'></form>"; echo "Browse a File to Upload For Record ".$TRN.": <br>"; echo "<form method='POST' enctype='multipart/form-data'>"; echo "<input type='hidden' name='b' value=".$b.">"; echo "<input type='hidden' name='TRN' value=".$TRN.">"; echo "<input type='hidden' name='User_Name' value=".$User_Name.">"; echo "<input type='hidden' name='TP' value=".$TP.">"; for ($a=0; $a < $b; $a++) { $filetoupload = "filetoupload".$a; echo "<input type='file' size='60' name='".$filetoupload."'><br>"; } echo "<input type='Submit' name=cmd value='Upload File'></form>";?>[/code] Quote Link to comment 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.