Profile Image upload is not saved

0

Hello,

I have a user registry where you can insert a profile photo. Each time I try to insert an image, messages are displayed. I have tried some solutions from the internet but unfortunately I could not solve my problem.

Messages:

Warning: move_uploaded_file (): The second argument to copy () function can not be a directory in

Warning: move_uploaded_file (): Unable to move

BD:

Name | Type

Image | blob

HTML:

<div class="form-group">
<label class="col-md-4 control-label" for="imagem">Imagem de perfil</label>
<div class="col-md-4">
<input type="file" name="imagem" class="btn btn-success"  accept="image/*" > 
</div>
</div>

PHP:

$tmpName = $_FILES['imagem']['tmp_name']; 
$imagem= $_FILES['imagem']['name']; 
$arqError = $_FILES['imagem']['error'];

if ($arqError == 0) {
        $pasta = './uploads/';
        $upload = move_uploaded_file($tmpName, $pasta);
    }

PHP to display the image:

<img src="uploads/<?php=$_FILES['imagem']['name'];?>">
    
asked by anonymous 24.06.2017 / 02:18

1 answer

1

As I mentioned in the comment above, the variable $pasta is only receiving the directory, not the file name. Change your code to the following and see if it works:

$tmpName = $_FILES['imagem']['tmp_name']; 
$imagem= $_FILES['imagem']['name']; 
$arqError = $_FILES['imagem']['error'];

if ($arqError == 0) {
        $pasta = './uploads/';
        $upload = move_uploaded_file($tmpName, $pasta.'imagem.jpg');
}
    
24.06.2017 / 02:31