Correcção para upload de ficheiros em Wordpress 2.5+
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2180
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3025
Warning: implode() [function.implode]: Argument to implode must be an array. in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3077
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 1827
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 2180
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3025
Warning: implode() [function.implode]: Argument to implode must be an array. in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3077
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3108
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3151
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292
Warning: Invalid argument supplied for foreach() in /home/adias/public_html/blog/wp-content/plugins/wp-syntax/geshi/geshi.php on line 3292
Desde de que actualizei o wordpress para a versão 2.5 e posteriormente para a 2.6, deixei de conseguir fazer upload de imagens utilizando o editor do WP.
Perdi quase uma semana e descobri que o problema é devido a um conflito com o módulo Mod Security do php Apache e na maior parte dos casos resolve-se adicionando as seguintes linhas ao ficheiro .htaccess na raís da instalação do WP:
1 2 3 4 5 6 | <IfModule mod_security.c> <Files async-upload.php> SecFilterEngine Off SecFilterScanPOST Off </Files> </IfModule> |
Infelizmente no meu caso específico isto não era suficiente e depois de uma semana a tentar descobrir uma maneira de corrigir o erro pedi ajuda ao apoio técnico do meu serviço de alojamento, que em poucas horas deu a solução que é muito parecida com a anterior:
1 2 3 4 5 | <IfModule mod_security.c> SecFilterScanPOST Off SecFilterEngine Off SecFilterInheritance Off </IfModule> |
Agora tanto o upload via flash com o upload via browser funcionam na perfeição! Espero que esta dica seja útil!
ACTUALIZAÇÃO: Confirma-se que é uma incompatibilidade com o Mod Security pois pode ler-se em http://www.modsecurity.org/:
ModSecurity v2.5.5
(June 6, 2008)
ModSecurity v2.5.5 is a maintenance release, which fixes a few bugs and compatibility problems (e.g. the WordPress upload issue).
ACTUALIZAÇÃO 2: O problema também está relacionado com a própria rede onde estamos ligados. Eu por exemplo, consigo fazer upload de imagens em casa, mas no trabalho o upload não funciona.


25 de Julho, 2008 às 13:50
o mod_security é um modulo do Apache e não do PHP.
não sei se desactivar o modulo terá sido uma boa opção, o bug pode simplesmente ser corrigido, colocando no wordpress o caminho para o upload de ficheiros como o por omissão que eles aconselham.
25 de Julho, 2008 às 16:18
Obrigado pela correcção. Quando à tua solução, tentei fazer isso mas continuou sem funcionar…