On our hosting server, I have two projects, where both have a module in our administrative area to manage images.
In the A project, the form is submitted to the server and the $_POST
array is received by the server with the image field loaded.
In the B project, the form is submitted to the server but the $_POST
array arrives empty to the server, although in Firebug I can see that the field and the loaded image have been sent.
Form
Same for project A and B
<form class="horizontal-form" enctype="multipart/form-data" method="post" action="#">
<div class="row-fluid">
<div class="span6">
<div class="control-group">
<label class="control-label">Carregar imagem</label>
<div class="controls">
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="input-append">
<div class="uneditable-input">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"></span>
</div>
<span class="btn btn-file">
<span class="fileupload-new">Selecionar ficheiro</span>
<span class="fileupload-exists">alterar</span>
<input type="file" class="default" name="img">
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">remover</a>
</div>
</div>
<span class="help-block">Escolha uma imagem para substituir a existente no site.</span>
</div>
</div>
</div>
<div class="span6">
<div class="control-group">
<label class="control-label">Pré-visualizar</label>
<div class="controls">
<div class="thumbnail item" style="width:244px">
<a href="http://www.meusite.com/caminho/para/imagem/imagem.jpg" title="Pré-visualização da imagem: imagem.jpg" class="fancybox-button">
<div class="zoom">
<img src="http://www.meusite.com/caminho/para/imagem/imagem.jpg"alt="" />
<div class="zoom-icon"></div>
</div>
</a>
<div class="details">
imagem.jpg
</div>
</div>
<span class="help-block">Pré-visualizar imagem existente</span>
</div>
</div>
</div>
</div>
<div class="form-actions text-right">
<button type="submit" class="btn blue"><i class="icon-ok"></i> Guardar alterações</button>
<a class="btn" href="?mod=website&call=images" title="">cancelar</a>
</div>
</form>
Firebug Information
-
Project A
-
Project B
I have already run a series of tests to understand what may be going on, some of which may be relevant to finding the solution to this problem:
PHP file with nothing more than the form above.
In the A and B project, the var_dump($_POST);
gives me an empty array.
Adding extra field of type hidden
or type text
to project form B solves the problem and the array of $_POST
starts arriving at the server in conditions.
Copy PHP file from the A project to the B project to check for any issues with the file itself. ), but the result is the same.
Verifying the .htaccess
files to find some Apache directives, but both files are strictly the same and contain no instructions other than:
# Use PHP5 AS DEFAULT
AddHandler application/x-httpd-php5 .php
# Frontpage
# Set the files to be ignored when ussing the directory list
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
IndexIgnore *
# BROWERS SERVER FILES VIEW DISABLE
Options -Indexes
# CUSTOM ERROR DOCUMENTS FOR APPACHE REDIRECT
ErrorDocument 400 /error/400.htm
ErrorDocument 401 /error/401.htm
ErrorDocument 403 /error/403.htm
ErrorDocument 404 /error/404.htm
ErrorDocument 500 /error/500.htm
Test in different browsers and different computers to exclude problems caused by browser or sessions.
The result was consistent across all tests, project A works fine, project B does not work.
Question
Why does the same form work in the A project, but fails in the B project, and tests with a simple form in both domains fail when you expect it in the project A work?