On Wed, Apr 1, 2009 at 2:10 AM, Roshan George <[email protected]> wrote:

> On Tue, 2009-03-31 at 10:26 +0530, Shahrukh Khan wrote:
> >      As suggested i have compared the MD5 hashes of two images located in
> > the same directory and it worked perfectly. But applying the same to
> > database doesn't yield any results. Please explain the concept for
> database
> > image comparing. I have tried every possible thing in the past 1week but
> > could not sort it out.
>
> This is certainly possible, and entirely straightforward. You would
> benefit more from reading:
>
> 1. How to retrieve information from a MySQL database¹ (assuming you're
> using MySQL)
> 2. What a BLOB is²
>
> > Is there a way to store the location of a file while we are going to
> > upload it. For eg: If i am trying to upload an image then including
> > the
> > image the location (url) of the image should also be stored in the
> > database.
> >
>
> This is also entirely possible. Instead of storing the image in the
> database, store it on the filesystem. When it is uploaded, change its
> name to a combination of the filename provided and the time (or hash
> thereof). Again, all of this is fairly straightforward, so you should
> just look at your textbooks and documentation on-line³ carefully.
>
> Please verify whether this code is correct or not........ Since this code
runs but it doesnot store the path in the database......


<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$errmsg = "";
if (! mysql_connect("localhost","root","")) {
        $errmsg = "Cannot connect to database";
        }
mysql_select_db("srk");
$a="create table sub(id int primary key not null auto_increment, loca
varchar(100))";
mysql_query($a);


if($_FILES['picupload']['tmp_name'] != "")
{
   $path = "images/" . basename($_FILES['picupload']['tmp_name']);
   $ext = strtolower(substr(strrchr($_FILES['picupload']['tmp_name'], '.'),
1));
   $allowedExt = array('jpg', 'png', 'gif', 'bmp');
   if(in_array($ext, $allowedExt))
   {
      if(move_uploaded_file($_FILES['picupload']['tmp_name'], $path))
      {
         $query = mysql_query("INSERT INTO sub (loca) VALUES('$path')");
         echo "The file was uploaded successfully.";
      } else
      {
         echo "There was an error uploading the file. Please try again
later.";
      }
   }

else
   {
      echo "The format is not supported.";
   }
}



?>
 <html>
<body>
    <form enctype="multipart/form-data" name="uploadform" method="post"
action="">
  <input name="picupload" type="file" />
  <input type="submit" name="Submit" value="submit" />
</form>
</body>
</html>


can anyone help me to store the path of file in database.......




Thanks in advance..........
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to