Jump to content

upload and insert multiple files and names


dflow

Recommended Posts

i would like to upload a number of images and insert their names into

imagelist_tbl

-- Table structure for table `image_list`
--

CREATE TABLE `image_list` (
  `imageID` int(11) NOT NULL auto_increment,
  `ProductID` int(11) NOT NULL,
  `imagename` varchar(255) collate utf8_unicode_ci NOT NULL,
  `imagelocation` varchar(255) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`imageID`)
)

i managed to create the following form and equivalent path/result page

i think i need to turn $numimages into an array or set a counter for each

 

in addition how would i insert alll of the images into the imagelist_tbl as ill need to loop

all of the created files uploaded?

<?php

//multiple_upload_form.php
?>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="multiple_upload_path.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>multiple Files Upload </strong></td>
</tr>
<?php
$i=1;
$numimages=$_GET['numimages'];
while($i<=$numimages)
  {
  echo '<tr><td>Select file<input name="ufile['.$i++.']" type="file" size="50"/></td></tr><tr>';

  }
?>

  <td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>


<?php
//multiple_upload_path.php

$i=1;
$numimages=$_GET['numimages'];
while($i<=$numimages)
  {
$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo "<img src=\"$path1\" width=\"150\" height=\"150\">";
echo "<P>";
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.