iceblox Posted July 18, 2007 Share Posted July 18, 2007 Hi Everyone, I got this script and i want to post the name of the file into mysql databse. Im not sure what variable to use. The script allows multiple uploads via a loop which is what is confusing me.. Here is the upload form <? $max_no_img=4; // Maximum number of images value to be set here echo "<form method=post action=addimgck.php enctype='multipart/form-data'>"; echo "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>"; for($i=1; $i<=$max_no_img; $i++){ echo "<tr><td>Image $i</td><td> <input type=file name='images[]' class='bginput'></td></tr>"; } echo "<tr><td colspan=2 align=center><input type=submit value='Add Image'></td></tr>"; echo "</form> </table>"; ?> Here is the code that deals with the upload <? while(list($key,$value) = each($_FILES[images][name])) { if(!empty($value)){ // this will check if any blank field is entered $filename = $value; // filename stores the value $add = "upimg/$filename"; // upload directory path is set echo $_FILES[images][name][$key]; // uncomment this line if you want to display the file type echo "<br>"; // Display a line break copy($_FILES[images][tmp_name][$key], $add); // upload the file to the server chmod("$add",0777); // set permission to the file. } } ?> And this is script im trying to use to post the file name to my database but im not sure what to replace "name" with.. $result = $db->sql_query("INSERT INTO ".$prefix."_rev_pending (name) VALUES ('".forSql($_POST["name"])."');"); Any help would be appreciated Phil Link to comment https://forums.phpfreaks.com/topic/60608-file-upload/ Share on other sites More sharing options...
iceblox Posted July 18, 2007 Author Share Posted July 18, 2007 Any one got any ideas? Link to comment https://forums.phpfreaks.com/topic/60608-file-upload/#findComment-301746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.