I am building an upload module, whereby I can upload a pdf, a image, and a word doc to a folder on the server. It's suppose to save the file path to my db, and when I query, show the path to these files.
This is the Error that I get:
Warning: rename() expects at most 3 parameters, 4 given in C:\apache2triad\htdocs\uploadtutorial\loadarticle1.php on line 68
What's my solution if I have more than 3 parameters?
Should I do another rename()?
line 67 - 68
$dest="oploads/".$_FILES[pdfpath][name] and $_FILES[imgpath][name] and $_FILES[wordpath][name];
rename($_FILES[pdfpath][tmp_name],$_FILES[imgpath][tmp_name],$_FILES[wordpath][tmp_name],$dest);
Just for interest sake, here is my hole upload page:
<?php
$self = $_SERVER['php_self'];
$rid = $_POST['rid'];
$articlename = $_POST['articlename'];
$pdfpath = $_POST['pdfpath'];
$imgpath = $_POST['imgpath'];
$wordpath = $_POST['wordpath'];
$model = $_POST['model'];
$price = $_POST['price'];
$description = $_POST['description'];
?>
<?php
if (isset($submit))
{
$conn= @mysql_connect( "localhost", "root", "password" )
or die( "Err:conn" );
$rs = @mysql_select_db( "cameo", $conn )
or die( "Err:conn1" );
$sql = "insert into release (articlename, pdfpath , imgpath , wordpath , model , price , description)
values ('$articlename', '$pdfpath', '$imgpath', '$wordpath' , '$model' , '$price' , '$description')";
$rs = mysql_query( $sql, $conn );
if($rs)
{
echo ("<table align=\"center\" width=\"500\" height=\"100\" border=\"2\" cellpadding=\"0\" cellspacing=\"0\">");
echo ("<tr>");
echo("<th>Product information has been added successfully for:</th>");
echo ("</tr>");
echo ("<td align=\"center\" >Name - $articlename</td>");
echo ("<tr>");
echo ("<td align=\"center\" ><img src=\"$imgpath\"></td>");
echo ("</tr>");
echo ("</table>");
}
else
{
echo ("Could not Add Product.");
}
}
?>
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['pdfpath']['name']);
$target_path = $target_path . basename( $_FILES['imgpath']['name']);
$target_path = $target_path . basename( $_FILES['wordpath']['name']);
$_FILES['pdfpath']['tmp_name'];
$_FILES['imgpath']['tmp_name'];
$_FILES['wordpath']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['pdfpath']['name']);
$target_path = $target_path . basename( $_FILES['imgpath']['name']);
$target_path = $target_path . basename( $_FILES['wordpath']['name']);
$dest="oploads/".$_FILES[pdfpath][name] and $_FILES[imgpath][name] and $_FILES[wordpath][name];
rename($_FILES[pdfpath][tmp_name],$_FILES[imgpath][tmp_name],$_FILES[wordpath][tmp_name],$dest);
$_FILES[userfile][width];
$_FILES[userfile][height];
echo "$userfile uploaded successfull";
if(move_uploaded_file($_FILES['pdfpath']['tmp_name'],$_FILES['imgpath']['name'], $_FILES['wordpath']['name'], $target_path))
{
echo "The file ". basename( $_FILES['pdfpath']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file ($articlename), please try again!";
}
?>