Saving image name in photo upload

I’m still confuse if I need to save my image in binary form inside my database or I’ll just save it in a folder and save the name of my image of my database. For now I’ll stick to save the name of my image.

Here is my code:


echo $id = $_GET['ID'];
$uploaddir = '../upload/';
$file = $uploaddir ."student_".basename($_FILES['uploadfile']['name']);
$file_name = "student_".$_FILES['uploadfile']['name'];

if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file))
	$query = mysql_query("UPDATE tbl_student
				    SET stud_Image= '$file_name'
				  WHERE id = '$id'"	) or die (mysql_error());
	echo "success";
	} else {
	echo "error";

I managed to save the image in a folder. My problem is I can’t save the name in my database.

Any help will do.

What error do you get?

There is no error shown. It such that I can’t find the image name inside my database.

here is my entire code.

$id = $_GET['stud_Id'];
<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8" />
	<title>Placeholder UI behaviours</title>
	<link rel="stylesheet" href="../css/style.css" />
	<link rel="stylesheet" type="text/css" href="../css/Ajaxfile-upload.css" />
	<script type="text/javascript" src="../js/Ajaxfileupload-jquery-1.3.2.js" ></script>
	<script type="text/javascript" src="../js/ajaxupload.3.5.js" ></script>
	<script type="text/javascript" >
		var btnUpload=$('#me');
		var mestatus=$('#mestatus');
		var files=$('#files');
		new AjaxUpload(btnUpload, {
			action: 'stud_image_act.php',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
                    // extension is not allowed
					mestatus.text('Only JPG, PNG or GIF files are allowed');
					return false;
				mestatus.html('<img src="../images/ajax-loader.gif" height="16" width="16">');
			onComplete: function(file, response){
				//On completion clear the status
				mestatus.text('Photo Uploaded Sucessfully!');
				//On completion clear the status
				//Add uploaded file to list
					$('<li></li>').appendTo('#files').html('<img src="../upload/student_'+file+'" alt="" height="120" width="130" /><br />').addClass('success');
				} else{

	<!--<form action="act_student.php" method="post">-->
		<!--image upload-->
		<div id="image">
			<div id="flash"></div>
			<div id="ajaxresult"></div>
    				<div id="files"><li class="success"><img src  ='../images/untitled.png'></li></div>
					<div id="me" class="styleall" style=" cursor:pointer;">
						<span style="  font-family:Verdana, Geneva, sans-serif; font-size:10px;">
							<span style="cursor:pointer;" onMouseOver = "insert();">Select image</span>
					<span id="mestatus" > </span>
				<span><input type = 'hidden' name = 'ID' id='ID' value = '<?php echo $id;?>'> </span>