Answer the question
In order to leave comments, you need to log in
Why might move_uploaded_file not work?
The file name is added to the database, but the image itself is not added to the folder.
$imgname= "name";
$ext = substr($_FILES["filename"]["name"], 1 + strrpos($_FILES["filename"]["name"], "."));
$img= $imgname.".".$ext;
$img = $_FILES["filename"]["name"];//проверка добавили ли картинку
move_uploaded_file($_FILES["filename"]["tmp_name"], "/user/images/logo/".$img);
$sql = mysql_query ("UPDATE `company` SET `img` = '$img' WHERE User_ID='$UserID'");
Answer the question
In order to leave comments, you need to log in
Check the permissions on the folder /user/images/logo/ should be 777
1. Check if the path /user/images/logo/
exists 2. Check if there is write access to this folder for the user on whose behalf php is running
Addition: to determine the file extension, it is better to use standard tools:
$img_info = pathinfo( $_FILES["filename"]["name"] );
$ext = $img_info["extension"];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question