this is my upload.php
document is succesfully uploading to a specific folder. now i want to download the document from that folder.
this is my search.php code
in this [code]echo ( '<img src="edit.ico" /><a href="download. php?pid=".$pid. "\">downloa d</a>');*/?>[code]
when i click this the download link it must download the
resume doc from 'upload' folder...
plz help?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Upload</title>
</head>
<?php
include('config.php');
?>
<body>
<?php
/*if ((($_FILES["file"]["type"] == "/doc")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 66000))*/
if(($_FILES["file"]["size"] < 66000) && ($_FILES["file"]["type"] == "application/msword") )
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
$filename = $_FILES["file"]["name"];
$filetype = $_FILES["file"]["type"];
$filesize = $_FILES["file"]["size"];
$tempfile = $_FILES["file"]["tmp_name"];
$query="insert into resume_upload (name, type, size,tmp_name) values ( '$filename','$filetype','$filesize','$tempfile' )";
mysql_query($query);
$candidatename = $_POST['cname'];
$gender = $_POST['gen'];
$email = $_POST['email'];
$phone = $_POST['ph'];
$qualification = $_POST['qual'];
$experience = $_POST['exp'];
$skills = $_POST['skills'];
$industry =$_POST['indus'];
$query1="insert into candidate (cname, gen, email, ph, qual, exp, skills, indus, res_title ) values ( '$candidatename','$gender','$email','$phone' ,'$qualification','$experience','$skills','$industry','$filename' )";
mysql_query($query1);
echo "<br>";
echo "File Details stored in database";
}
}
}
else
{
echo "Invalid file. Please Upload Word Document";
}
;
?>
</body>
</html>
this is my search.php code
Code:
<?php
include('lock.php');
include("config.php");
$var = @$_GET['q'] ;
$trimmed = trim($var);
// rows to return
$limit=10;
if ($trimmed == "")
{
echo "<p>Please enter a search...</p>";
exit;
}
/*if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}*/
$query = "select * from candidate where cname like \"%$trimmed%\" || skills like \"%$trimmed%\" || exp like \"%$trimmed%\" || indus like \"%$trimmed%\" || qual like \"%$trimmed%\" ORDER BY cid ";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>";
}
if (empty($s)) {
$s=0;
}
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
echo "<p>You searched for: "" . $var . ""</p>";
echo "Results";
echo "<br>";
$count = 1 + $s ;
echo "<center>";
echo "<table CELLPADDING=10 border =1 bgcolor='lightgrey'>";
echo "<tr>";
echo "<th>Candidate Name</th>";
echo "<th>Email Id</th>";
echo "<th>Qualification</th>";
echo "<th>Experience</th>";
echo "<th>Skills</th>";
echo "<th>Resume</th>";
while ($row= mysql_fetch_array($result)) {
?>
<tr>
<td> <?php echo $row["cname"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td><?php echo $row["qual"]; ?></td>
<td><?php echo $row["exp"]; ?></td>
<td><?php echo $row["skills"]; ?></td>
<td>
<?php echo ( '<img src="download.gif" /><a href="download.php">Download</a>' ); ?>
</td><td>
<?php
/*$pid= '$_GET[pid]';
echo ( '<img src="edit.ico" /><a href="download.php?pid=".$pid."\">Download</a>');*/?>
</td>
</tr>
<?php
}
$currPage = (($s/$limit) + 1);
echo "<br />";
if ($s>=1) {
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><<
Prev 10</a>  ";
}
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search Results</title>
</head>
<body>
</body>
</html>
when i click this the download link it must download the
resume doc from 'upload' folder...
plz help?
Comment