Hi,
I have two pages to upload an image for specific client.
the code of the page where I choose the image from file for specific client is:
<?php
require("headerloggedin.php");
?>
<?php
$clientid = $_GET["clientid"];
$query = "SELECT * FROM clients WHERE clientid = $clientid";
$resultset = $db->query($query);
while($row = mysql_fetch_array($resultset))
{
?>
<div id="content">
<table>
<tr>
<td colspan="3"><p id='clientname' align="center"><?php echo $row["clientname"];?></p></td>
</tr>
<tr>
<form enctype="multipart/form-data" method="post" action="addworkprocess.php">
<input type="hidden" name="idofclient" value="<?php echo $clientid;?>"/>
<td>
<p id="text">Add Work:</p>
<input type="file" name="0" id="box">
</td>
<td>
<p id="text">Month Completion:</p>
<select name="month" id="box">
<option value="">-Select Month-</option>
<?php
$months = array("January","February","March","April","May","June","July","August","September","October","November","December");
foreach ($months as $month):
?>
<option value="<?php echo $month; ?>"<?php if ($row['status'] == $month): ?> selected="selected"<?php endif; ?>><?php echo $month; ?></option>
<?php endforeach; ?>
</select>
</td>
<td>
<p id="text">Year of Completion:</p>
<?php
// lowest year wanted
$cutoff = 2010;
// current year
$now = date('Y');
// build years menu
echo '<select name="year" id="box">' . PHP_EOL;
for ($y=$now; $y>=$cutoff; $y--)
{
echo '<option value="' . $y . '">' . $y . '</option>' . PHP_EOL;
}
echo '</select>' . PHP_EOL;
?>
</td>
</tr>
<tr>
<td><input id="formbtn" type="submit" value="Add" /></td>
</tr>
</form>
</table>
<div id="smallbtn">
<ul>
<li><a href="portfoliologgedin.php">Back</a></li>
</ul>
</div>
</div>
<?php
}
?>
<?php
require("footerloggedin.php");
?>
and the code of the process page is:
<?php
require("headerloggedin.php");
?>
<div id="content">
<?php
date_default_timezone_set('Europe/Malta');
if (!empty($_POST["idofclient"]))
{
$clientid = $_POST["idofclient"];
$month = $_POST["month"];
$year = $_POST["year"];
$datetime = date('Y-m-d H:i:s');
$filecount=count($_FILES);
for($j=0;$j<$filecount;$j++)
{
if($_FILES[$j]['size']<=0 )
continue;
$fileno=$j+1;
$filetitle = $_FILES[$j]['name'];
if($filetitle!="")
{
$fileext = substr($_FILES[$j]['name'], strrpos($_FILES[$j]['name'], '.'));
$uploaddir = "../images/work/";
$max_size = "108388608";//"2621440";//"8388608";//""6291456";//"5242880";//"1048576";//"512000";//8388608
if ($_FILES[$j]['type'] == "text/html")
{
$var_msg.= "Incorrect File Extension for file {$fileno}!<br>";
$insert=false;
break;
}
else
{
if($_FILES[$j]['size'] > $max_size)
{
$var_msg.= "File Size Is Too Big for file {$fileno}! Max size is 4 MB<br>!";
$insert=false;
break;
}
else
{
move_uploaded_file($_FILES[$j]['tmp_name'],$uploaddir.$file_name);
move_uploaded_file($_FILES[$j]['tmp_name'], $uploaddir.$filetitle);
$query = "INSERT INTO gallery (clientid, folder, file, filext, month, year) VALUES ('$clientid', '$uploaddir', '$filetitle', '$fileext', '$month', '$year')";
$db->query($query);
echo "<p id='text'>"."The file with the name of ".$filetitle." is uploaded."."</p>";
}
}
}
}
}//end file array
?>
<div id="smallbtn">
<ul>
<li><a href="portfoliologgedin.php">Back</a></li>
</ul>
</div>
</div>
<?php
require("footerloggedin.php");
?>
my problem is when I click on the add button, the code didn't upload the information. can anyone help me to find the problem?
Thanks.
marifard