uploading multiple files path in the database

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 multiple files path in the database

Post 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";

}

       
       
}
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

'Picture1' and 'picture1' will not make reference to the same array value. Array keys are case sensitive.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post 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
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Well, the directory clearly doesn't exist. move_uploaded_file() will not create the directory if it doesn't already exist.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post 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
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

move_uploaded_file() requires two arguments.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post 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')";
       
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

move_uploaded_file() is being given one argument. It needs to destination to move it to.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there's no function being called for the part following the "&&."
Post Reply