php - I want to store image into remote database -
i have tried , found server side coding this. don't know write in client side. want store image on image view remote database.
<?php $host="localhost"; // host name $username="root"; // mysql username $password=""; // mysql password $db_name="q"; // database name \ // connect server , select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select db"); // username , password sent 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 q(q)values('$fe')"; $res=mysql_query($qu); if($qu) { echo "success"; } else { echo "mahender".mysql_error(); } ?>
some notes code security:
- your php code unprotected. careful , try divide code modules. possible sql injection filename on query.
- don't forget sanitize inputs (as in case, filename, filesize, file format...)
- you should create hash (sha1, md5...) using file's name , use store file on files path , on database entry
now refering client side of file uploader, check this link.
Comments
Post a Comment