Using Photo Upload script in my form....please help

Hi Forum,

I am using photo upload option in my form…but it seems not to be working.

Here’s some info…please help me as I’ve tried everything…but no success.


if($_POST['work']=="addfback")
{
    // Create an object.
	//print_r($_POST);exit;
	
	$userfback = new userfback;
	
	$_POST['fb_date'] = date("Y-m-d");
	
	$set = array(
	"fb_name"=>$_POST['fdname'],
	"fb_email"=>$_POST['email'],
	"fb_contact"=>$_POST['fdcontact'],
	"fb_state"=>$_POST['fddrpval'],
	"fb_city"=>$_POST['fbcity'],
	"fb_photo"=>$_POST['file'],
	//"url"=>$_POST['url'],
	"fb_comment"=>$_POST['fdtext']
	);
	
	$fbimg = $userfback->upload_file_art($_FILES['file'],"img/uimg/");
	//$logo1 = $banner->upload_file_art1($_FILES['logo1'],"../../banner/banner/");
	
	$result = $userfback->add($_POST,$fbimg); 
	
	if($result){
		
		$_SESSION["msg"] = "Thank You! for the precious feedback.";
		
		$url =  "../fbuser.php";

		header("Location: $url");
		
		die;

/*		print("<script language='javascript'>location.href='".$url."'</script>");
		die;
*/	}
	else {
		$userfback->setsession($set);
		$_SESSION["msg"] = "Error! unable to add your feedback, please try again.";
		//header("Location: ../add_banner.php");
		print("<script language='javascript'>location.href='../fbuser.php'</script>");
		die;
	}
	
}


Here I am adding it to my database


class userfback extends functions
{
	function add($post,$fbimg)     //Add the news letter details to the database.
	{
		$sql_add = "insert into feedback(`fb_photo`,`fb_name`,`fb_date`,`fb_email`,`fb_contact`,`fb_state`,`fb_city`,`fb_comment`) values('$fbimg','".$post['fdname']."','".$post['fb_date']."','".$post['email']."','".$post['fdcontact']."','".$post['fddrpval']."','".$post['fbcity']."','".$post['fdtext']."')";
		$result_add  = mysql_query($sql_add);
		return true;
	}
}


Its not showing any error but in my table its not adding any value.

Here’s the table structure for that field.

fb_photo
varchar(225)
utf8_general_ci
No
none

Here’s the function uploading image.


function upload_file_art($file, $path)
	{	
		$filename = rand(1000,9999)."_".$file["name"];
		$tempName = $file["tmp_name"];
		$UPLOAD_FILE =  $path."/".$filename;	
		$target = $path."thumb/";
		$new_w = 41;
		$new_h = 46; 
		ini_set('memory_limit', '50M');
		if($tempName){
			//system("chmod 7777 $UPLOAD_FILE");
			if(move_uploaded_file($tempName, $UPLOAD_FILE))
			{
				$this-&gt;createthumb($filename,$path,$target,$new_w,$new_h);
				return  $filename;
			}
			else
				return false;
		}
		else{
			return false;
		}
	}

I’ve tried everything…and I need help…please check this for me.

Any of your suggestion would be highly appreciated.

Thanks a ton!

What enctype do you have on your form? If there isnt one or its the wrong one then no FILES array is generated and no errors are alerted.

it should be multipart/form-data

ok, thanks spike, now I am having this error:

Warning: move_uploaded_file(img/uimg/1887_Jackob.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/83/4759683/html/DID_index/classes/functions.class.php on line 140

Hi can anyone tell me wt’s the meaning of this error.

This is rather simple as the warning message itself says it does not find the image

img/uimg/1887_Jackob.jpg
. Check folders have been created as img/uimg and 1887-Jackob.jpg file has been uploaded to the directory.