-1
I need to rename images when uploading, however, some images the code can not take the extension to finish the process correctly.
Thus ending: maisguarapari_5c4a3bec18563. (i.e., saving the image without the extension)
I try several times with the same image, but without success.
This is one of the images that I can’t get its extension from the code: https://www.maisguarapari.com.br/certo.jpg
Important to remember that, I take photos by my phone, the dozens of photos I send, some photos the code cannot catch its extension.
PHP
$nome = $_FILES['userfile']['name'];
$extensao = strtolower(end(explode('.', $nome)));
$nomenovoorigem = uniqid('maisguarapari_');
$nomenovo = $nomenovoorigem.".".$extensao;
HTML
<form class="frm_mural" action="/mural-gravar" method="post" enctype="multipart/form-data">
<input class="entrada_frm_mural" required="required" name="userfile" type="file">
<button class="entrada_frm_mural_enviar" type="submit">Enviar</button>
</form>
What is the
print_r
from $_FILES when this happens?– Woss
@Andersoncarloswoss I used this code
print_r($_FILES);
and returned thatArray ( )
– Gladison
Even sending the file through the form? The result seems that no file was sent. By the way, you had not asked this question?
– Woss
@Andersoncarloswoss yes, but in another context. This case is very specific.
– Gladison
@Andersoncarloswoss make the direct test by the link with the code that Bulfaitelo sent https://www.maisguarapari.com.br/teste.php
– Gladison
The problem with being very specific is that it turns out to be non-reproducible. I recommend that you edit the question by putting all the possible information in the situation that the problem occurs, such as the request that the browser does, values of the superglobal in PHP, if JS influences the upload, server logs, etc.
– Woss
Let’s go continue this discussion in chat.
– Gladison
@Andersoncarloswoss Even using only his code, IE, totally dry, does not work to get the extension of the image that provided the link.
– Gladison