Answer the question
In order to leave comments, you need to log in
Why files are not uploaded to the server (PHP)?
There is a clean OS, ubuntu 14.04. It costs apache + php5. The site has the usual form:
<form name="contact-from" id="contact-form" action="" method="post" enctype="multipart/form-data">
<input style="display: flex;align-items: center;height: auto;padding: 15px 10px;" name="photo" type="file" class="input-full main-input required,email" placeholder="Фотография">
<button class="button-primary pull-right" type="submit" style="border:none;">
</form>
$_FILES['photo']['name'] = strtolower($_FILES['photo']['name']);
$_FILES['photo']['tmp_name'] = strtolower($_FILES['photo']['tmp_name']);
$allow = array("jpg", "jpeg", "png", "gif");
$ext = substr($_FILES['photo']['name'], stripos($_FILES['photo']['name'], ".") + 1);
if(array_search($ext, $allow) !== false){
$fname = md5(date("d.m.Y H:i:s") . rand(0, 100000) . $_FILES['photo']['name']);
if(move_uploaded_file(realpath(dirname($_FILES['photo']['tmp_name'])), DIR . "/uploads/feedbacks/" . $fname . "." . $ext)){
$photo = $fname . "." . $ext;
}
}
$file = file_get_contents($_FILES['photo']['tmp_name']);
file_put_contents(DIR . "/uploads/feedbacks/" . $fname . "." . $ext, $file);
Answer the question
In order to leave comments, you need to log in
In general, it turned out very stupid.
$_FILES["photo"]["tmp_name"] = strtolower($_FILES["photo"]["tmp_name"]);
check what rights the apache has, and what group it has, maybe the apache does not have the necessary rights, although the folder has rights 777, xs, check it anyway.
Turn on the output of errors and warnings, if not enabled. Perhaps there are errors, but they are suppressed.
Try to just transfer the file, do not change its name, transfer at least what has come.
So far, smarter ideas have not come.
UPD: specify the folder with an absolute path from document_root.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question