I need to upload an image to database and save it inside a folder so I can display the image by giving the path to that folder. I have already coded this but there is a problem it in saving inside a folder. It saves the path to the database and correctly storing details but it dosen't save inside the folder which I have created inside my project.Folder name is also same but I cannot fix this problem. Please help me find to correct this. I've been struggling with this for a long time.
public function save()
{
$url = $this->do_upload();
//$title = $_POST["title"];
//$this->main_m->save($title, $url);
}
private function do_upload()
{
$type = explode('.', $_FILES["pic"]["name"]);
$type = strtolower($type[count($type)-1]);
$url = "./images/".uniqid(rand()).'.'.$type;
if(in_array($type, array("jpg", "jpeg", "gif", "png")))
if(is_uploaded_file($_FILES["pic"]["tmp_name"]))
if(move_uploaded_file($_FILES["pic"]["tmp_name"],$url))
return $url;
return "";
}