problem in uploading file & saving it to mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BasantSingh
Forum Newbie
Posts: 6
Joined: Wed Mar 05, 2008 3:19 am

problem in uploading file & saving it to mysql

Post by BasantSingh »

Hi Friends,
I am new to PHP , so please forgive me if I ask any silly questions.
I want to upload a file & then store it in mysql.But I am facing some problems .I am pasting my code please have a look at it & tell me how to overcome this problem.

html code:---


<form action="index.php?action=1030" method="post" enctype="multipart/form-data" name="uploadform">
<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" class="box" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>


PHP code--------------

$fileName = $_FILES['uploadform']['name'];
$tmpName = $_FILES['uploadform']['tmp_name'];
$fileSize = $_FILES['uploadform']['size'];
$fileType = $_FILES['uploadform']['type'];

$uploaddir = getcwd();
echo $uploaddir."\\".$fileName;


if(move_uploaded_file($_FILES['uploadform']['tmp_name'],$upload_dir."\\".$filename))
{
echo "file moved....";
}
else {
echo "better luck next time";
}

problem i am facing that each time the move_uploaded_file is returning false.
Please help...me.....it's urgent.......
thanx...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: problem in uploading file & saving it to mysql

Post by Christopher »

Do this to show how $_FILES is structured.

Code: Select all

echo '<pre>' . print_r($_FILES, 1) . '</pre>';
(#10850)
Post Reply