Heyy...i'm trying to save the attachment file location in mydb...the thing is it's just saving the file name
eg.database.txt
i want it to look like this
C:/bla/bla/test
my codes
addtask.php
<html>
<head>
<title>Task Management System</title>
<link rel="stylesheet" href="Appcss.css" type="text/css"/>
<script src="datetimepicker_css.js"></script>
<script type="text/javascript">
// Javascript function which takes care for multiple uploads
var attachmentlimit = 5; // Limiting maximum uploads to 5
var attachmentid = 1;
function attachmore() { // Function is called when user presses Attach Another File
attachmentid += 1;
document.getElementById('attachmentdiv').innerHTML += '<div id="attachmentdiv_' + attachmentid + '" style="margin-top:5px"><input type="file" id="attachment_' + attachmentid + '" name="attachment_' + attachmentid + '" size="30" onchange="document.uploadattachments.submit();"/></div>';
if(attachmentid == attachmentlimit) {
document.getElementById('addanother').style.display='none';
}
}
function testSelect(form)
{
var multipleVar = form.list.options[form.list.selectedIndex].value
if(form.comments.value == "")
{
form.comments.value = multipleVar + '\n';
}
else if (form.comments.value != "")
{
var insertedMultipleVar = form.comments.value;
form.comments.value = insertedMultipleVar + multipleVar + '\n'
}
}
</script>
</head>
<body>
<form name=form5 method="post">
<table width="100%" border=1 bordercolor="blue" bgcolor="blue">
<tr>
<td align=right><input value="HOME" type="submit" size="25" onclick="form5.action='mainpage.php'"><input value="LOGOUT" type="submit" size="25" onclick="form5.action='logout.php'"></td> <!--creating User ID textbox-->
</tr>
</table>
</form>
<center>
<FORM METHOD=GET name="form" > <!--Creating a form with actions--> <!--Body CSS--> <!--Inserted images-->
<h1>Add New Task</h1>
<hr>
<table border=1 bordercolor=black><tr><td>
<table>
<h3><u>Task Details</u></h3>
<tr>
<td>Task Name : </td><td><b><input name="taskname" type="text" size=20></td></tr>
<tr><td>Assign By : </td><td><b><select name="aname"> <!--Name of the combo box-->
<?php
//for each row we get from mysql, echo a form input
while ($row = mysql_fetch_array($result1)) {
echo "<option>$row[Name]</option>\n";
}
?></td></tr>
<tr><td>Responsible Staff : </td><td><select name="list"> <!--Name of the combo box-->
<?php
//for each row we get from mysql, echo a form input
while ($row1 = mysql_fetch_array($result)) {
echo "<option>$row1[Name]</option>\n";
}
?>
</select><input type="button" value="Add!" onClick="testSelect(this.form);"></td></tr>
<tr><td></td>
<td><textarea name="comments" cols="40" rows="4" ></textarea></td></tr>
<tr><td>Start Date :</td><td><input type="date" name="sdate" id="sdate" size=10><img src="images/cal.gif" onclick="javascript:NewCssCal('sdate','yyyymmdd')" style="cursor:pointer"/></td></tr>
<tr><td>End Date :</td><td><input type="date" name="edate" id="edate" size=10 name="edate"/></input><img src="images/cal.gif" onclick="javascript:NewCssCal('edate','yyyymmdd')" style="cursor:pointer"/></td></tr>
<tr><td>Description</td><td><textarea name="comments1" cols="40" rows="5" onfocus="clearContents(this);">Describe Your Task....</textarea></td></tr>
<tr><td>Attachment</td><td>
<!-- Form taking care of the uploads, notice that the frame target is the iframe contained inside, to which it fires upload.php -->
<form id="uploadattachments" enctype="multipart/form-data" name="uploadattachments" target="attachmentiframe" action="upload.php" method="post">
<div id="attachmentdiv" >
<iframe name="attachmentiframe" style="display:none"></iframe>
<div id="attachmentdiv_1" style="margin-top:5px">
<input type="file" id="attachment_1" name="attachment_1" size="50" onchange="document.uploadattachments.submit();"/>
</div>
</div>
<!-- div showing error message for invalid file type -->
<div id="typeerrormessage" style="display:none;margin-left:30px">
<font color=#990000 size=1>Only png, jpg and gif file type are supported</font>
</div>
<!-- div showing error message for exceeded file size -->
<div id="sizeerrormessage" style="display:none;margin-left:30px">
<font color=#990000 size=1>File exceeded maximum allowed limit of 100 Kb</font>
</div>
<div id="addanother" >
<a href="javascript:void(0)" onclick="attachmore();"><font size=2>Attach another file</font></a>
</div>
</form></td></tr>
<tr><td></td><td><input type="submit" value="Add Task!" onclick="form.action='taskregistration.php';"></td></form></tr></table></td></tr></table>
</center></body>
</html>
taskregistration.php
<title>Task Management System</title>
<link rel="stylesheet" href="Appcss.css" type="text/css"/>
<?php
session_start();
if($_GET["taskname"] &&$_GET["aname"] && $_GET["comments"] && $_GET["sdate"] && $_GET["edate"] && $_GET["comments1"] && $_GET["attachment_1"]) //getting the value from the register form(if fail or empty) promt user
{
require_once 'connection_details.php'; //Calling the Connection Detail php file
$tbl_name="task"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$taskname=$_GET["taskname"];
$aname=$_GET["aname"];
$rname=$_GET["comments"];
$sdate=$_GET["sdate"];
$edate=$_GET["edate"];
$desc=$_GET["comments1"];
$link=$_GET["attachment_1"];
echo $taskname;
echo $aname;
echo $rname;
echo $sdate;
echo $edate;
echo $desc;
//sql commands to insert the data into the database
$sql="INSERT INTO $tbl_name (TaskName,AssignBy,ResponsStaff,StartDate,EndDate,Description,AFile)VALUES('".$taskname."','".$aname."','".$rname."','".$sdate."','".$edate."','".$desc."','".$link."')"; //sql query defined
$result=mysql_query($sql) or mysql_error(); //runs the query
echo "<h1>you have registered sucessfully</h1>";
header("refresh:1;url=MainPage.php" ); //links to main login page after one second delay
}
else {
print"invalid data";
//header("refresh:1;url=addtask.php" );
}
?>
upload.php
<?php
// Set the upload target directory
$target_path = "Data/";
for($i=1;$i<=5;$i++) {
$attachments = 'attachment_'.$i;
$attachmentdiv = 'attachmentdiv_'.$i;
$FileName = $_FILES[$attachments]['name'];
// Check if filename is empty
if($FileName != "") {
$FileType = $_FILES[$attachments]['type'];
$FileExtension = strtolower(substr($FileName,strrpos($FileName,'.')+1));
// Check for supported file formats
if($FileExtension != "doc" && $FileExtension != "docx" && $FileExtension != "pdf" && $FileExtension != "txt") {
echo "<script type='text/javascript'>parent.document.getElementById('typeerrormessage').style.display = 'inline';</script>";
}
else {
$FileSize = round($_FILES[$attachments]['size']/1024);
// Check for file size
if($FileSize > 300) {
echo "<script type='text/javascript'>parent.document.getElementById('sizeerrormessage').style.display = 'inline';</script>";
}
else {
$FileTemp = $_FILES[$attachments]['tmp_name'];
$FileLocation = $target_path.basename($FileName);
// Finally Upload
if(move_uploaded_file($FileTemp,$FileLocation)) {
// On successful upload send a message to corresponding attachmentdiv from which the file came from
echo "<script type='text/javascript'>parent.document.getElementById('".$attachmentdiv."').innerHTML = '<input CHECKED type=\"checkbox\"><a href=\"http://abhinavsingh.com/webdemos/upload/".$FileName."\" target=\"_blank\"><font size=2><b>".$FileName."</b> <i>(".$FileType.")</i> ".$FileSize." Kb</font>';</script>";
echo "<script type='text/javascript'>parent.document.getElementById('typeerrormessage').style.display = 'none';</script>";
echo "<script type='text/javascript'>parent.document.getElementById('sizeerrormessage').style.display = 'none';</script>";
}
else {
echo "There was an error uploading the file, please try again!";
}
}
}
}
}
?>
can someone guide me...thank you in advance