testing directory existance before creating it

This commit is contained in:
Pogodaanton 2020-07-19 16:16:34 +02:00
parent 6d4a3ba11f
commit 3208fc16f8
2 changed files with 8 additions and 2 deletions

View File

@ -45,7 +45,10 @@ switch ($type) {
$temp_dir = "../.temp";
$chunk_path = $temp_dir . "/" . $file_id . "-";
mkdir($temp_dir);
if (!file_exists($temp_dir)) {
mkdir($temp_dir);
}
if ($type === "video-gif-upload") {
// Uploaded file size must not exceed 2gb

View File

@ -133,7 +133,10 @@ class FileUploader
{
$target_name = $GLOBALS["upload_directory"] . $this->file_id . "." . $this->file_extension;
try {
mkdir($GLOBALS["upload_directory"]);
if (!file_exists($GLOBALS["upload_directory"])) {
mkdir($GLOBALS["upload_directory"]);
}
if (!move_uploaded_file($this->file["tmp_name"], $target_name)) {
error("Uploading image did not succeed. Check whether the destination is writeable.");
}