Error trying to write to server after running --Letsencrypt (help a PHP newbie)

Hello guys. Could some charitable soul indicate the direction? :blush:

I am having an error in my PHP code or in the server write permission. I have already isolated the code responsible for saving the image on the server, but since I understand little of PHP, I do not know exactly what may be hindering the writing on the server. I only know that my code saved the images perfectly until last week, but after I ran the --letsencrypt command, it stopped writing to the server.

Thanks and any indication of the way will already be of great help. :sweat_smile:

This is the code I am using to write the image to the server:

<?php
// ImgUpload.php

require_once("settings.php");

$erro = false;
$erro_cont = 0;
$erro_mensagem = '';

$loja = false;
if(isset($_GET['loja']) && !empty($_GET['loja'])) if($_GET['loja'] == 1) $loja = true;

if(file_put_contents($logdir."upload.log", date("Y-m-d H:i:s") . "\n" . print_r($_FILES, true) . "\n" , FILE_APPEND | FILE_TEXT) < 1) {
	$erro = true;
	$erro_cont++;
	$erro_mensagem .= $erro_cont . ') Log nao foi gravado' . "\n";
}

// Se trata de acesso para Upload?
if (count($_FILES) < 1 || !isset($_FILES['imagem'])) {
	$erro = true;
	$erro_cont++;
	$erro_mensagem .= $erro_cont . ') Nao foi enviado arquivo em POST ou variavel POST nao recebe nome "imagem"' . "\n";
}

if(!$erro) {
	
	$micro_date = microtime();
	$date_array = explode(" ",$micro_date);

	if($loja) $uploaddir_ = 'store/';
	else $uploaddir_ = 'film/' . date('Y/m/',$date_array[1]);
	$uploaddir = $uploaddir_base . $uploaddir_;

	// Cria diretório se não existe
	if (!file_exists($uploaddir)) {
		if(!mkdir($uploaddir, 0755, true)) {
			$erro = true;
			$erro_cont++;
			$erro_mensagem .= $erro_cont . ') Nao foi possivel criar o diretorio ' . $uploaddir . "\n";
		}
	}

	// Verifica o tipo de arquivo
	$extensao = '';
	switch ($_FILES['imagem']['type']) {
		case 'image/png':
			$extensao = 'png';
			break;
		case 'image/jpeg':
			$extensao = 'jpg';
			break;
		case 'image/gif':
			$extensao = 'gif';
			break;
		case 'application/octet-stream':
			$name_ext = end(explode(".",$_FILES['imagem']['name']));
			if($name_ext == 'gif' || $name_ext == 'png' || $name_ext == 'jpeg' || $name_ext == 'jpe' || $name_ext == 'jpg')
				$extensao = $name_ext;
			else {
				$erro = true;
				$erro_cont++;
				$erro_mensagem .= $erro_cont . ') Erro de tipo de arquivo (somente: png, jpg, jpeg, jpe e gif)' . "\n";
			}
			break;
		default:
			$erro = true;
			$erro_cont++;
			$erro_mensagem .= $erro_cont . ') Erro de tipo de arquivo (somente: png, jpg e gif)' . "\n";
			break;
	}

	if(!$erro) {

		$date = date("Ymd-His",$date_array[1]);
		$uploadfile_name = $date . "-" . round($date_array[0]*1000000) .'.' . $extensao;
		$uploadfile = $uploaddir . $uploadfile_name;

		if (!move_uploaded_file($_FILES['imagem']['tmp_name'], $uploadfile)) {
			$erro = true;
			$erro_cont++;
			$erro_mensagem .= $erro_cont . ') Nao foi possivel fazer o upload do arquivo. Veja mais:' . "\n" . print_r($_FILES['imagem'], true) . "\n";
		}
		
	}

}

if($erro) {
	echo $erro_mensagem;
}
else {
	header('Content-Type: application/xml; charset=utf-8');
	echo '<?xml version="1.0"?>'."\n<root>\n<imagem>https://bigshopping.com.br/wp-content/uploads/" . $uploaddir_ . $uploadfile_name . "</imagem>\n</root>";
}

?>

Thanks @fghafoor!

Just delete the force-ssl-domain.com.conf file from /etc/nginx/conf.d

And then goto /etc/nginx/sites-available and open the config filed named just domain.com from the directory and add listen 80; after server {

Restarted server, cleaned cached and it all worked fine after that. Http and Https both with http as default.