I have a html code as below through which I give image file as input

 <input name="photo_file" type="file" />

then anather php file to insert record into database code is as below

<?php
define('GW_UPLOADPATH', 'images/');
$picture=$_FILES['photo_file'];
$target= GW_UPLOADPATH . $picture ;

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("demo", $con);
if (move_uploaded_file($_FILES['photo_file']['tmp_name'], $target))
{
mysql_query("INSERT INTO feedback (photo)VALUES ('".$picture."')");


echo "record inserted";
}
mysql_close($con);
?> 

I got error as below
Notice: Undefined index: photo_file in C:\wamp\www\shilpa\send.php on line 3

will anybody help me I tried all possible ways:( now needs help Thank you in advance

$_FILES['photo_file'] does not exist for some reason. Good practice is to check for existance first:

if(!isset($_FILES['photo_file'])) {

    // handle the wrror the way you see fit
    die('Error uploading the file');
}

// code for normal processing

Line 3 should get the name of the file instead of the array:

$picture=$_FILES['photo_file']['name'];  // Gets the original file name.

Also make sure your form has the attribute enctype="multipart-formdata" so it posts FILE data to your php file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.