Form data not recived in php file

form as follows
-------------------------------------------------------------
 <form id="imgupload" method="post" type="submit" enctype="multipart/form-data">
                  <span><strong>Select image to upload:</strong></span>
          <input type="file" name="fileToUpload" id="fileToUpload"><br/><br/>
          <input type="text" name="img_name" id="img_name" placeholder="Enter Name of Image"><br/><br/>
          <input type="submit" value="Upload Image" id="save" name="save">
        </form>
-----------------------------------------------------
jquery as follows
------------------------------------------------------
$(document).ready(function(){
    $('.sidenav').sidenav();
     $('.collapsible').collapsible();

     
      $(function () {
        $('#imgupload').bind('submit', function () {
          $.ajax({
            type: 'post',
            url: 'slider.php',
            data: $('#imgupload').serialize(),
            success: function (data) {
              alert('form was submitted');
              window.alert(data);
            }
          });
          return false;
        });
      });
  });
-----------------------------------------------------------
php code as follows
-----------------------------------------------
<?php
include('db_connection.php'); 

if(isset($_POST['save']))
{
	if(isset($_FILES['fileToUpload']['name']))
	{
		
		 $img_name = $_POST['img_name'];
		 $target = 'pictures/'; 
		 $target = $target.basename($_FILES['fileToUpload']['name']);
		
		 if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target))
		  {
			  $query="INSERT INTO slider (name,image_name) VALUES ('$img_name','$target')";
		      if(mysqli_query($conn,$query))
		      {
	             echo 'image path inserted successfully to mysql database and image into pictures folder';
	             header('admin_panel.php');
		      }
		      else
		      {
	             echo 'image not inserted to mysql database';
		      }
			
			
		  }
		  else
		  {
		        echo 'Image is not stored into picture folder';
	      }

	}
	else
	{
		echo "File is not coming";
	}
}
else
{
	echo "Values not coming";
} 



			
			echo 'Image is successfully stored into picture folder';
		  }
		  else
		  {
		        echo 'Image is not stored into picture folder';
	      }*/


?>

Feel free to ask a question. If your not sure how to post on a forum this will help.

Sponsor our Newsletter | Privacy Policy | Terms of Service