Jump to content

uploading multiple files w/ php


mikefrederick

Recommended Posts

help please, I can't figure out how to upload multiple files. I have the form w/ 2 upload fields called image1 and image2. Then I am using this script which will upload the file names to a database and it will upload the first file to a folder on the site called "propertyimages/" and I need to know how to make the script also copy the other file to the folder. here is the script, which contains some additional information being submitted to the db:

 

 

<?php

require_once "connect.php";

 

$filename = $HTTP_POST_FILES['image1']['name'];

$filenametwo = $HTTP_POST_FILES['image2']['name'];

 

$path= "../propertyimages/".$filename;

$pathtwo= "../propertyimages/".$filenametwo;

if (copy($HTTP_POST_FILES['image1']['tmp_name'], $path))

{

 

$addname = $_POST['Addname'];

$addemail = $_POST['Addemail'];

$addphone = $_POST['Addphone'];

$adddesc = $_POST['Adddesc'];

$addact = $_POST['Addact'];

$addrates = $_POST['Addrates'];

$addamen = $_POST['Addamen'];

 

 

mysql_select_db($database_localhost, $localhost);

$query = "INSERT INTO addnew (addname,addemail,addphone,adddesc,addamen,addact,addrates,imageone,imagetwo) VALUES('$addname','$addemail','$addphone','$adddesc','$addamen','$addact','$addrates','$filename','$filenametwo')";

$Rs = mysql_query($query, $localhost) or die(mysql_error());

 

 

Header ('Location:index.php');

 

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/72383-uploading-multiple-files-w-php/
Share on other sites

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.