473,698 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

upload the resume and store in database

118 New Member
hi,

i wrote a code to upload a resume in mysql database and download that one .
But in my database name,type,size of the file stored but content of the file not stored. So in my database content filed is empty.plz tell that what's the problem in my code.


[PHP]

<?
include("db.php ");
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmpname'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp = fopen($tmpName, 'rb');
$content = fread($fp, filesize($tmpNa me));
$content = addslashes($con tent);
fclose($fp);

if(!get_magic_q uotes_gpc())
{
$fileName = addslashes($fil eName);
}

$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($qu ery) or die('Error, query failed');

echo "<br>File $fileName uploaded<br>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>
<form method="post" enctype="multip art/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_ SIZE" value="2000000" >
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><inp ut name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>

</body>

</html>
[/PHP]

And i got the errors as

Warning: fread(): supplied argument is not a valid stream resource in e:\project\grap hic\docu.php on line 11

Warning: fclose(): supplied argument is not a valid stream resource in e:\project\grap hic\docu.php on line 13
Sep 18 '08 #1
2 7649
Dormilich
8,658 Recognized Expert Moderator Expert
hm, what's the difference between $filename and $tmpname?
what are the values of the vars (line 5 to 8) (var_dump())? maybe this gives a hint...

regards
Sep 18 '08 #2
anup44
1 New Member
You have done One silly mistake at


$tmpName = $_FILES['userfile']['tmpname'];
here you have written [tmpname] instead if ['tmp_name']
so you should have to write

$tmpName = $_FILES['userfile']['tmp_name'];
Dec 1 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2455
by: Sean Dotson | last post by:
I have a form that passes variables to an asp file and then uploads a file. For some reason the request.form is not getting the info from the form. It's returning blanks. Any insight would be appreciated.... Here is the asp file <HTML> <HEAD> <TITLE>File Upload Results</TITLE>
4
9913
by: weiwei | last post by:
Hi All I want to upload either image or word document into either access or SQL server database so far I am doing some small testings and what I can do is upload the file from first page and display at the next page with (both image or word are working fine). however, I cann't insert them into the database, Plus, what type should I use in access database? anyone who has this type of project, please help me out below is my current test...
3
22286
by: Stephan | last post by:
Hi all, I am new to access and I face the following "issue": I would like to create a database, to which users can upload files (=pdf, doc, xls...). The files shall be stored locally on a server. The database needs to be accessed via Access form (no html, asp,...) as we don't have an internal web server running. I would like to create a form that allows the user to browse his local harddrive, select the file and upload it directly...
9
20894
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at rapidshare news : http://images.rapidshare.com/software/rsapi.pl If you test it you will see that you can upload one file at time. I try to modify it in that way that script can read a text file with the names of the files i want to...
6
3683
by: priyakollu | last post by:
hi guyz!, im using win xp, xampp version 2.5 Requirement: Upload resume from form and store in database and this would be "register.html" file later i want to retrieve that resume from database n display it in "registerdisplay.php" cud u plz guide me how to acheive this........ i have hosted this site in godaddy.com problem is mysql_connect('localhost', 'mysql_user', 'mysql_password'); what should i write
2
7649
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in the db-file-to-disk.asp file, what I want to do is the user has to field out this fied before...
0
2670
by: ll | last post by:
I'm working with 'pure ASP upload' script which is designed to redirect to an alert/error message, should a file larger than the set limit be attempted to be uploaded. The problem is that, while smaller files do upload successfully, the script does not catch the larger files and rather than a specific error message in Firefox (and IE7), I just get the following: ------------------------------------ The connection was reset The...
7
3730
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to rebuild. Does anyone have any suggestions on what I may have wrong. I am not sure if I built my table to store the picture id's correctly. Maybe a field type or something. <form name="UpdatePropertyPicture" method="POST"...
4
4888
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to mydirectory, but for some reason, I am getting different file names on the database. Here is the full code: please do serach on kewword "database" to see where I added my database code - that where I need help with. And here the link where I got it...
0
8683
marktang
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...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
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...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
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...
0
7739
agi2029
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...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.