mysql - php image upload cant copy the actual file to the destination folder -
mysql - php image upload cant copy the actual file to the destination folder -
i having problem when trying upload image mysql database has 3 fields: id(auto increment), username , image location. code inserting image location database not copying actual image "profile_pics" directory. please assist.
this code:
<?php $connection=mysql_connect("localhost", "root", ""); $choose_db=mysql_select_db("ninjacity", $connection) or die (mysql_error()); if ($_session['user'] && $_post['submit']) { function check() // check if pic exists { $username=$_session['user']; $choose_db; $sql_check="select * profile_pics username='$username'"; $res_check=mysql_query($sql_check) or die (mysql_error()); homecoming mysql_num_rows($res_check); } $name=$_files['image']['name']; $tmp_name=$_files['image']['tmp_name']; $check=check(); if ($check==1) { echo "you have profile pic. if wish alter it, please utilize 'edit profile' section"; } else { $name; $tmp_name; $username=$_session['user']; $location="profile_pics/$name"; move_uploaded_file($tmp_name, "profile_pics/".$name); $choose_db; $sql="insert profile_pics values ('$_post[id]', '$username', '$location')"; $res=mysql_query($sql) or die (mysql_error()); print "image uploaded"; } } else { echo "please fill fields"; } ?>
have checked permission of profile_pics directory . should 777.
or issue related path (destination path of directory )you have used in move_uploaded_file .
php mysql
Comments
Post a Comment