image upload error

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
parikhankit009
New php-forum User
New php-forum User
Posts: 21
Joined: Tue Nov 16, 2010 5:11 am
Location: India

Thu Nov 25, 2010 5:30 am

Yes you need to remove [] brackets from input tag name userfile[].
you need to place only name="userfile"

Let me know whether it works or not.

meerakarthik

Wed Feb 09, 2011 9:00 pm

check this out

Code: Select all

<?php include("connect.php"); ?>
<?php

$fname = trim($_POST['fname']);
$lname = trim($_POST['lname']);
$gender = trim($_POST['gender']);
$phone = trim($_POST['txtPhone']);
$email = trim($_POST['mail']);
$location = trim($_POST['location']);
$zipcode = trim($_POST['zip']);
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

      
      $tmpName  = $_FILES['image']['tmp_name'];  
       
      // Read the file 
      $fp      = fopen($tmpName, 'r');
      $data = fread($fp, filesize($tmpName));
      $data = addslashes($data);
      fclose($fp);
      

      // Create the query and insert
      // into our database.
     /* $query = "INSERT INTO socialdb ";
      $query .= "(image) VALUES ('$data')";
      $results = mysql_query($query, $link);
      */
      // Print results
      
      
}
else {
  
}

   
 $query = "INSERT INTO socialdb(fname,lname,gender,dob,phone,email,location,zipcode,image)VALUES('$fname','$lname','$gender','$dob','$phone','$email','$location','$zipcode','$data')";
 $results=mysql_query($query,$link);
 if($result)
{
echo "Registered Successfully";
}
 
?>

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests