I need to add a photo update function.
HTML form:
<form action="scripts/setImage.php" method="post">
<h3>Set my image:</h3>
Choose photo:<br><br>
<input type="file" name="file"><br>
<input type="submit" value="Sumbit">
</form>
PHP:
$file = $_POST['file'];
if (isset($_POST['file'])) {
$db->UPDATE("UPDATE users SET image = LOAD_FILE('$file') WHERE id = $idLogged");
}
And this doesn't work ;/ I think I can't use $_POST with files. I tried also $_FILES but it doesn't work as well.
<form action="scripts/setImage.php" method="post" enctype="multipart/form-data">
<h3>Set my image:</h3>
Choose photo:<br><br>
<input type="file" name="file"><br>
<input type="submit" value="Sumbit">
</form>
<?php
$file =addslashes(file_get_contents($_FILES['file']['tmp_name']));
if (isset($file)) {
$db->UPDATE("UPDATE users SET image = '$file' WHERE id = $idLogged");
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With