1
I have a code pad to do upload but every time I try to do the upload appears a message saying "Please send files with the following extensions: jpg, png or gif". I am trying to do the upload file docx
and I’ve specified that:
$_UP['extensoes'] = array('docx', 'xlsx', 'pdf', 'jpg', 'png', 'gif', 'jpeg' );
Why the message appears even though I have "released" other extensions?
$extensao = @strtolower(end(explode('.', $_FILES['arquivoJuridico']['name'])));
if (array_search($extensao, $_UP['extensoes']) === false) {
echo "Por favor, envie arquivos com as seguintes extensões: jpg, png ou gif";
}
It’s just that if I don’t put @ the system fails for no reason! I took this code from a website and it already came with this direct comparison with false.
– GustavoSevero
Does not exist for no reason in programming. There is an error there. And it is probably this error that is causing the next error. The
@
He just switched places and made it harder to find the cause. That’s what I said, unless you have a very strong reason and only those who have a lot of experience know how to identify a very strong reason, the@
error omission never should be used. Print the contents of$_FILES['arquivoJuridico']['name']
preferably with guards in the string:echo "|" . $_FILES['arquivoJuridico']['name'] . "|";
to see if there is a filename there. And post the error.– Maniero
$extension = @strtolower(end(explode('.', $_FILES['fileJuridic']['name'])); if (array_search($extension, $_UP['spellers']) === false) { echo "Please send files with the following extensions: jpg, png or gif"; } When shooting @: Strict standards: Only variables should be passed by Reference in C: Program Files (x86) Vertrigoserv www marco php reclamatorias zanellaP1.php on line 700 Strict standards: Only variables should be passed by Reference in C: Program Files (x86) Vertrigoserv www marco php reclamatorias zanellaP1.php on line 700
– GustavoSevero
Edit your question to put additional information.
– Maniero
@Gustavosevero, The error of
@
is easy to arrange, just you take the return ofexplode
and play in a variable and then callstrtolower() e end()
. Like this:$arr = explode('.', $_FILES['arquivoJuridico']['name']);$extensao = strtolower(end($arr));
more details on this question– rray
So? $extension = strtolower(end(explodes('. ', $_FILES['archivedJuridic']['name'])); $arr = explodes('. ', $_FILES['fileJuridic']['name']); $extension = strtolower(end($arr));
– GustavoSevero
@I’m trying to reproduce the mistake and I can’t. http://ideone.com/IqWiW6. It is exactly your code the only thing I have done differently is initialize the
$FILES
on hand since I cannot receive the data from outside and even if I could, it would be difficult to reproduce exactly the same situation. I believe your problem is not of code but of environment.– Maniero
@bigown, you can simulate the
Strict Standards...
in ideon adding 2 lines at the beginning, know there it seems that it has some setting to not display warnings, example with warnings– rray
Simulating the Strict Standards?
– GustavoSevero
I discovered my problem... I was forgetting the "enctype="Multipart/form-data"
– GustavoSevero
As I was saying the problem is not in this presented code.
– Maniero