Error while uploading file to the database

1

I'm trying to upload a file to the database. Except that instead of sending the file itself, it is sending the temporary location of it.

My code looks like this:

$arquivo = $_FILES['arquivo'];
$name = $arquivo['name'];
$file_tmp = $arquivo['tmp_name'];
$file_bin = mysqli_real_escape_string(file_get_contents($file_tmp));


$conn = mysqli_connect('localhost', 'root', '', 'files');
$sql = "INSERT INTO malote_arq (arquivo, nome) VALUES('$file_bin', '$name')";

mysqli_query($conn, $sql);

C: wamp mpphpF1F2.tmp

    
asked by anonymous 03.10.2014 / 19:23

1 answer

2

This happens because the temporary filename of the file is not just a path to the file. So before you should know where your server saves the temporary files and add the path to that file and add it. Anything like this

 file_get_contents(/path/folder/temp/nome_do_arquivo);//este é um caminho inventado

If you do not know the path, save the temporary file anywhere you know after passing as an argument to file_get_contents

You can find the directory in php.info () in upload_tmp_dir.

    
03.10.2014 / 19:47