Can't move file php with move_uploaded_file -
executing following code, error:
warning: move_uploaded_file(/chroot/home/xxxx/public_html/project/img/uploads/ee9b37faf0390088b3bd4b1eb0d3b862.jpg): failed open stream: permission denied in /chroot/home/xxxx/public_html/project/php/class/edit_profile_form.php on line 101 warning: move_uploaded_file(): unable move '/tmp/phpbxxojs' '/chroot/home/xxxx/public_html/project/img/uploads/ee9b37faf0390088b3bd4b1eb0d3b862.jpg' in /chroot/home/xxxx/public_html/project/php/class/edit_profile_form.php on line 101
code:
$target_dir = "/chroot/home/xxxx/public_html/project/img/uploads/"; $db_target_dir = "/~xxxx/project/img/uploads/"; $this->target_file = $target_dir . md5($this->username); $db_target_dir=$db_target_dir.md5($this->username); $imagefiletype = pathinfo($_files["photo"]["name"],pathinfo_extension); echo $imagefiletype; if($imagefiletype != "jpg" && $imagefiletype != "png" && $imagefiletype != "png" && $imagefiletype != "jpeg" && $imagefiletype != "gif" ){ $this->message="errore: formato not supported"; return false; } $this->target_file=$this->target_file.".".$imagefiletype; $db_target_dir=$db_target_dir.".".$imagefiletype; if ((!move_uploaded_file($_files["photo"]["tmp_name"], $this->target_file)) || ($_files["photo"]["size"] > 150000)){ $this->message="error2"; return false; } $this->target_file=$db_target_dir; }
i have permission write on folder, can't figure out why have problem
thank in advance
the answer permissions. said you have permission write folder, user, under web server runs?
have @ owner of temp file that's being created - www-data
or such like. ensure user has write permissions destination folder.
Comments
Post a Comment