1
I am in need of a help to develop a code to store images in the database, so far I have not achieved anything... I don’t know if it is better to store the file in a directory and only the name in the bd, and mainly how to do this...
<form method="post" enctype="multipart/form-data" action="cadastrar.php">
<table>
<tr><td>imagem:</td><td><input type="file" size="60" name="arq" value=""></td></tr>
</table>
</form>
$arq_name = $_FILES['arq']['name']; //nome do arquivo
$arq_size = $_FILES['arq']['size']; //tamanho do arquivo
$arq_tmp = $_FILES['arq']['tmp_name']; //nome temporário do arquivo
//grava no DB
mysql_query("INSERT INTO users (foto) VALUES ('$arq_name')");
//grava a img no diretório
move_uploaded_file($arq_tmp, "imagens/".$arq_name);
Now I just have to be able to pull the images by id...
what you’ve tried friend?
– Guerra
I edited the question, see if you understand...
– Bruno Ferreira
Read this - http://answall.com/questions/42886/salvar-no-banco-de-dados-conte%C3%Bado-bin%C3%A1rio-de-uma-imagem
– Edilson
So, I don’t know if it would look better on a directory or on the db itself...
– Bruno Ferreira
Read the answers to this link, in attention to the last that has some good references on the use, and then maybe you can know which to use.
– Edilson