U
U
Uzair Izha2015-11-04 18:52:42
PHP
Uzair Izha, 2015-11-04 18:52:42

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

2 answer(s)
T
TheLostRoot, 2015-11-04
@TheLostRoot

Check the permissions on the folder /user/images/logo/ should be 777

A
Alexander Latyshev, 2015-11-04
@magalex

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 question

Ask a Question

731 491 924 answers to any question