Page 1 of 1

uploading multiple files path in the database

Posted: Tue Jan 16, 2007 1:43 pm
by franknu
i want to upload multiples file path in the database the problem is that it is not updating anything but it is not displaying anything saying what the problem is here is my code

Code: Select all

$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']));

 $fullpath = $uploaddir . $uploadfile1;

 $filename1=$_POST['name']. "1";
 $result= move_uploaded_file($_FILES['picture1']['tmp_name'],  $fullpath."/". "$filename1");

 if($result==1)
{

    $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','$fullpath','$fullpath','$User_Name','$Password')";


$result = mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error()); 

echo "picture1 front of business uploaded";

}

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

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

  if ($result==1)

  {

   $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')";


$result = mysql_query($sql) or die("SQL Error: $sql<br>" . mysql_error()); 

echo " <br> Picture2  uploaded";

}

       
       
}

Posted: Tue Jan 16, 2007 1:59 pm
by aaronhall
'Picture1' and 'picture1' will not make reference to the same array value. Array keys are case sensitive.

Posted: Tue Jan 16, 2007 2:06 pm
by franknu
ok i fixed that

this is my new error message

Code: Select all

Warning: move_uploaded_file(/home/townsfin/public_html/business_images/JOSEFAWEB.jpg/1) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/townsfin/public_html/html_forms/insert_data.php on line 107

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpGsGnrb' to '/home/townsfin/public_html/business_images/JOSEFAWEB.jpg/1' in /home/townsfin/public_html/html_forms/insert_data.php on line 107

Posted: Tue Jan 16, 2007 2:18 pm
by aaronhall
Well, the directory clearly doesn't exist. move_uploaded_file() will not create the directory if it doesn't already exist.

Posted: Tue Jan 16, 2007 2:32 pm
by franknu
i fixed the move_uploaded_file


ok my problem now is that it is going to two diffrent rows in my database

please help

Posted: Tue Jan 16, 2007 3:07 pm
by franknu
ok, this is ny new code here is my error message

Warning: Wrong parameter count for move_uploaded_file() in /home/townsfin/public_html/html_forms/insert_data.php on line 130

Posted: Tue Jan 16, 2007 3:28 pm
by feyd
move_uploaded_file() requires two arguments.

Posted: Tue Jan 16, 2007 3:59 pm
by franknu
ok maybe i am not understandin but this is my code

Code: Select all

If (move_uploaded_file ($_FILES['Picture1']['tmp_name']) && 
     ($_FILES['Picture2']['tmp_name'])) 

{

  $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')";
       
}

Posted: Tue Jan 16, 2007 4:02 pm
by feyd
move_uploaded_file() is being given one argument. It needs to destination to move it to.

Posted: Tue Jan 16, 2007 4:08 pm
by franknu
If (is_uploaded_file ($_FILES['Picture1']['tmp_name'], $fullpath1) &&
($_FILES['Picture2']['tmp_name'], $fullpath2))

error

Parse error: syntax error, unexpected ',' in /home/townsfin/public_html/html_forms/insert_data.php on line 131

Posted: Tue Jan 16, 2007 4:13 pm
by feyd
there's no function being called for the part following the "&&."