Answer the question
In order to leave comments, you need to log in
How to make check with $_FILES condition work?
Hello, I'm asking for help.
There is a form
<form method="GET" enctype="multipart/form-data">
<input name="messimg" type="file" id="messimg"/>
<h3><textarea name="message" id="textarea"></textarea><input type="submit" name="button" id="button" value=""/></h3>
</form>
if($_FILES['messimg']['name']) {
$path = "chat_images/" . time() . $_FILES['messimg']['name'];
move_uploaded_file($_FILES['messimg']['tmp_name'], "../" . $path);
}
$today = date("F j, Y, g:i a");
//вставляем значения
if($message && $path){
$stm = $dbh->prepare("INSERT INTO `messages` (`author`, `message`, `time`, `avatar`, `img`) VALUES ('$author', '$message', '$today', '$avatar', '$path')");
$stm->execute();
}
Answer the question
In order to leave comments, you need to log in
specify absolute paths, well, read the documentation again, on the topic of error handling
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question