this is my upload.php -
<!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>
-
-
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?
Jul 29 '10
12 3448
this is my code download.php -
<?php
-
include('config.php');
-
$filename = @$_GET['id'] ;
-
echo "$filename";
-
-
if('$filename'==NULL)
-
{
-
echo "<message>file name missing </message>";
-
exit;
-
}
-
-
-
if(file_exists("upload/".$filename)==false)
-
{
-
echo "<message>file missing in the server</message>";
-
exit;
-
}
-
-
-
$rfilename = realpath("upload/".$filename); //server specific
-
-
$file_extension = strtolower(substr(strrchr($rfilename,"."),1));
-
-
switch( $file_extension )
-
{
-
case "pdf": $ctype="application/pdf"; break;
-
case "exe": $ctype="application/octet-stream"; break;
-
case "zip": $ctype="application/zip"; break;
-
case "doc": $ctype="application/msword"; break;
-
case "xls": $ctype="application/vnd.ms-excel"; break;
-
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
-
case "gif": $ctype="image/gif"; break;
-
case "png": $ctype="image/png"; break;
-
case "jpe": case "jpeg":
-
case "jpg": $ctype="image/jpg"; break;
-
default: $ctype="application/force-download";
-
}
-
-
header("Pragma: public"); // required
-
header("Expires: 0");
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-
header("Cache-Control: private",false); // required for certain browsers
-
header("Content-Type: $ctype");
-
header("Content-Disposition: attachment; filename=".$filename.";" );
-
header("Content-Transfer-Encoding: binary");
-
header("Content-Length: ".@filesize($rfilename));
-
@readfile("$rfilename");
-
//unlink($rfilename); //to delete the file after dwonload
-
?>
-
-
-
-
-
its now working buddy. thanks.
i used
inside the code. thats why i am not getting the correct contents. i remove that code,now its working.... thank you!
I can see there is 5 new line after your ?>
it would change the content of the file. to make sure check the file size in the server and the file size that you upload i guess you will get few bytes differetn
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ASP Spam Fighter |
last post by:
Hello all,
I don't know how to get around this one... If anybody can help me
with this problem, I would appreciate it very much.
I've been trying to send a (large) file to the browser via a download
page that uses a file download component. The file downloads fine,
except that Internet Explorer refuses to browse to a different page
while the file is downloading! I don't understand why it does that
and I don't know how to fix this...
|
by: Vasu |
last post by:
Hi,
I have a requirement to download a file from the web
site using a client tool.
Iam writing a C# program to download using WebRequest,
HttpRequest, WebResponse and
so on. The problem Iam having is to navigate thru
multiple pages. I have to login
|
by: Killingkids |
last post by:
hello, everyone...im facing a big problem in my final year project, hope that u all can help me solve the problem ...
i was doing a mobile web application which enable student to check the college information through mobile, however i just use simulator to test my system...
one of modules or function was enable the student to downloads some notes which in txt file format through mobile.Hence, i tested using IE,it does not appear any problem, i...
|
by: Killingkids |
last post by:
hello, everyone...im facing a big problem in my final year project, hope that u all can help me solve the problem ...
i was doing a mobile web application which enable student to check the college information through mobile, however i just use simulator to test my system...
one of modules or function was enable the student to downloads some notes which in txt file format through mobile.Hence, i tested using IE,it does not appear any problem, i...
|
by: Geethu03 |
last post by:
In my application i want to download the files in web by using the java or JSP program. please help me to do this program.
Thanks and Regards,
Geethu.
| |
by: keerthyragavendran |
last post by:
hi
i'm downloading a single file using multiple threads...
how can i specify a particular range of bytes alone from a single
large file... for example say if i need only bytes ranging from
500000 to 3200000 of a file whose size is say 20MB...
how do i request a download which starts directly at 500000th byte...
thank u
cheers
|
by: cypherkro |
last post by:
Hi
I have a requirement to automatically download a file using a WebBrowser control without having the "Download File" pop up windows display.
I cannot use Webclient!!
I am using VS2005, .net2 and the application is a windows application.
Does anyone have a solution to automatically downloading the file from a WebBrowser control.
Thanks in Advance
|
by: pplers |
last post by:
I have a list of files (zip, rar) that require cookies to download them. So i would like to know how to do it....
|
by: vinodkus |
last post by:
dear sir/madam
I have to write a code for download file using asp. please help me
thanks in advance
|
by: colinod |
last post by:
I am trying to get my site to download mp3 files without having to right click - save as on a link.
I have found this code, which works as long as the file names are short, if they get a bit long it just opens a blank page, can anyone help
<%@Language="VBScript"%>
<%Option Explicit%>
<%Response.Buffer = True%>
<%
On Error Resume Next
Dim strPath
strPath = CStr(Request.QueryString("file"))
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |