Jump to content

uploading multiple files path in the database


franknu

Recommended Posts

ok i have this code but i been trying to get it to work for weeks, i want to upload multiple files and save the path in the database, PLEASE HELP

My error message is:


picture one uploadedPicture2 uploaded
Warning: Wrong parameter count for move_uploaded_file() in /home/townsfin/public_html/html_forms/insert_data.php on line 134


[code=php:0]

define ("$uploaddir", "/home/townsfin/public_html/business_images/");


// $uploadfile1 = $_FILES['Picture1']['name'];

if(isset ($_FILES['Picture1']))
{

If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&&
is_uploaded_file($_FILES['Picture2']['tmp_name']));
{

// $fullpath1 = $uploaddir . $uploadfile1;
$today=date("m-d-y");

$filename1=$_POST['name']. "1";

$result= move_uploaded_file($_FILES['Picture1']['tmp_name'],  $uploaddir .$filename1);

if($result==1)
{

  echo"picture one uploaded";
}

$uploadfile2= $_FILES['Picture2']['name'];
//$fullpath2=$uploaddir . $uploadfile2;

$filename2= $_POST['name']. "2";
$result = move_uploaded_file($_FILES['Picture2']['tmp_name'], $uploaddir .$filename2);

  if ($result==1)

  {

  echo"Picture2 uploaded";

}
  if (move_uploaded_file ($_FILES['Picture1']['tmp_name']) &&
    ($_FILES['Picture2']['tmp_name']. $uploaddir))

{

  $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',
'$fullpath1','$Headline','$Slogan2','$Description1',
'$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";
  mysql_query($sql)or die(mysql_error());
}

}
}
?>
[/code]
Link to comment
Share on other sites

Change: define ("$uploaddir", "/home/townsfin/public_html/business_images/");
to $uploaddir = "/home/townsfin/public_html/business_images/";

add this to the top and show what it displays:
print '<pre>';
print_r($_FILES);
print_r($_POST);
print '</pre>';
Link to comment
Share on other sites

i am getting a parser error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/townsfin/public_html/html_forms/insert_data.php

on

[code=php:0] if (move_uploaded_file ($_FILES['Picture1']['tmp_name']) &&
    ($_FILES['Picture2']['tmp_name'], "$uploaddir"))
[/code]

[code=php:0]

$uploaddir= "/home/townsfin/public_html/business_images/" ;


// $uploadfile1 = $_FILES['Picture1']['name'];

if(isset ($_FILES['Picture1']))
{

If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&&
is_uploaded_file($_FILES['Picture2']['tmp_name']));
{

// $fullpath1 = $uploaddir . $uploadfile1;
$today=date("m-d-y");

$filename1=$_POST['name']. "1";

$result= move_uploaded_file($_FILES['Picture1']['tmp_name'],  $uploaddir .$filename1);

if($result==1)
{

  echo"picture one uploaded";
}

$uploadfile2= $_FILES['Picture2']['name'];
//$fullpath2=$uploaddir . $uploadfile2;

$filename2= $_POST['name']. "2";
$result = move_uploaded_file($_FILES['Picture2']['tmp_name'], $uploaddir .$filename2);


';
print_r($_FILES);
print_r($_POST);

print '';

  if ($result==1)

  {

  echo"Picture2 uploaded";

}
  if (move_uploaded_file ($_FILES['Picture1']['tmp_name']) &&
    ($_FILES['Picture2']['tmp_name'], "$uploaddir"))

{

  $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',
'$fullpath1','$Headline','$Slogan2','$Description1',
'$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";
  mysql_query($sql)or die(mysql_error());
}

}
}
?>
[/code]

Link to comment
Share on other sites

picture one uploadedArray ( [Picture1] => Array ( [name] => chicken1.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpyAHJGB [error] => 0 [size] => 300291 ) [Picture2] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) [Picture3] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) [Picture4] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) [Picture5] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) ) Array ( [First_Name] => [Last_Name] => [Owner_Address] => [State] => [City] => [Zip] => [Tel] => [Email] => [Position] => [Comments] => [BusinessName] => [Member_Status] => [Slogan] => [Website] => [Keyword] => [Fax] => [Business_Address] => [make] => Massachusetts [type] => Lawrence [Categories] => [Headline] => [Slogan2] => [Description1] => [Description2] => [Description3] => [Contact2] => [User_Name] => [Password] => )
Warning: Wrong parameter count for move_uploaded_file() in /home/townsfin/public_html/html_forms/insert_data.php on line 137

i added
print_r($_FILES);

that is my display now
Link to comment
Share on other sites

ok now it says everything has been uploaded but nothing shows on the database

here is my new changes

[code=php:0]


define ("$uploaddir", "/home/townsfin/public_html/business_images/");


$uploadfile1 = $_FILES['Picture1']['name'];

if(isset ($_FILES['Picture1']))
{

If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&&
is_uploaded_file($_FILES['Picture2']['tmp_name']));
{

  $fullpath1 = $uploaddir . $uploadfile1;
$today=date("m-d-y");

$filename1=$_POST['name']. "1";

$result= move_uploaded_file($_FILES['Picture1']['tmp_name'],  $uploaddir .$filename1);

if($result==1)
{

  echo"picture one uploaded";
}

$uploadfile2= $_FILES['Picture2']['name'];
$fullpath2=$uploaddir . $uploadfile2;

$filename2= $_POST['name']. "2";
$result = move_uploaded_file($_FILES['Picture2']['tmp_name'], $uploaddir .$filename2);

print_r($_FILES);


  if ($result==1)

  {

  echo"Picture2 uploaded";

}
  if (move_uploaded_file ($_FILES['Picture1']['tmp_name'], $uploaddir)) {

  $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',
'$fullpath1','$Headline','$Slogan2','$Description1',
'$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";
  mysql_query($sql)or die(mysql_error());
}

}

}

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.