0

I have tried and also found some server side coding for this. I don't know what to write in client side. I want to store the image on image view to remote database.

<?php
    $host="localhost"; // Host name
    $username="root"; // Mysql username
    $password=""; // Mysql password
    $db_name="q"; // Database name
    \
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form     $myusername=$_GET['ID'];
    //$mypassword=$_GET['email'];
    $target1="Login/".$_FILES['sr']['name'];
    move_uploaded_file($_FILES['sr']['tmp_name'], $target1);
    //$passport=$target1;
    $fe=$_FILES['sr']['name'];

    $qu="INSERT INTO q(q)VALUES('$fe')";
    $res=mysql_query($qu);
    if($qu) {
        echo "success";
    }
    else {
        echo "mahender".mysql_error();
    }
?>
Weather Vane
  • 33,872
  • 7
  • 36
  • 56

2 Answers2

0

You can send a form to your php file in client side.

<form action="your_php_file.php" method="post" enctype="multipart/form-data">
   <input type="file" name="sr" accept="image/*">
   <input type="submit">
</form>
Muhammed Tanriverdi
  • 3,230
  • 1
  • 23
  • 24
0

Some notes about code Security:

  • Your PHP code is completely unprotected. Be careful about that and try to divide your code by modules. Possible SQL Injection with Filename on your query.
  • Don't forget to sanitize inputs (as in that case, filename, filesize, file format...)
  • You should create a Hash (SHA1, MD5...) using your file's name and use it to store your file on your files path and on your database entry

Now refering to the client side of the file uploader, check this link.

Community
  • 1
  • 1
Filipe Paulo
  • 134
  • 6
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – nalply Jun 13 '15 at 06:25