uploading more the one file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

uploading more the one file

Post by franknu »

ok, I have this script that i can upload one file and save the path in the database. The problem is that i want to upload more than one file. Please help


the colums in my database where i want to upload the file are called Picture2 and Picture3

here is my code

Code: Select all

$uploaddir = '/home/townsfin/public_html/business_images/';
$uploadfile = $_FILES['Picture1']['name']; // 

if(!empty($_FILES['Picture1'])){
   var_dump($uploaddir);

   var_dump($_FILES['Picture1']['size']);
   var_dump($_FILES['Picture1']['error']);
   var_dump($_FILE);
   var_dump($_FILES['Picture1']['type']);
   var_dump($_FILES['Picture1']['name']);
}

$fullpath = $uploaddir . $uploadfile;
if (move_uploaded_file($_FILES['Picture1']['tmp_name'], $fullpath)){
   echo("File Uploaded");
   $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`,
 `Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`,
 `Picture2`,`Picture3`,`User_Name`,`Password`)

Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword',
'$fullpath','$Headline','$Slogan2','$Description1',
'$Description2','$Description3','$Picture2','$Picture3','$User_Name','$Password')";


   $result = mysql_query($sql);
   if (!$result){
      echo "Error inserting data: " . mysql_error();
   }
}
else {
   echo ("file no uploaded!");
   print_r($_FILES);
   echo realpath('./');
}


Please help
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Save the files into your filesystem instead of database. It's generally easier and faster. Then google for php multiple file upload you should find plenty of help.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

oh only the path is being save in the database

everything i see in google and books only works for a on file.

i was thinking that maybe if i add the ['Picture2], [Picture3]

it would work i was just hoping to get it some help with the same code i have
because i know it works
Post Reply