开发者

$_POST goes empty after adding a new input type "file"

I'm not finding a way to understand and fix this and I've done a lot.

I've got a script, wish is a simple form, that sends a file trough POST. The second file, process the info.

By default, I give to the user a few fields, one of them being a input field of type "file" and there's also, a few "hidden" one's, that gives me values to work with on POST.

I found that, when adding a new input of type "file", the $_POST returns array 0, even $_FILES returns nothing. I have no idea how to fix this, and it works just fine when keeping the default input box of type "file".

<form id="formulario" enctype="multipart/form-data" action="projectos_processar.php" method="POST">

    Modo inserir projecto item!<br/><br/>
    <label>Imagem de apresentacao: </label>

    <input id="img_p_child" type="file" name="img_p_child" cols="100" value="" class="validate['required','image']" /><br/>

    <br/>
    <br/>

    <input type="file" id="video" name="video" class="validate['required','video']" cols="100">

    <br/>                       
    <br/>
   开发者_JAVA技巧 <hr>
    Publicar o item ? <br/>
    <br/>
    <br/>                       

    Sim <input type="radio" name="published" value="1"><br>
    Nao <input type="radio" name="published" value="0" checked="true"><br>

    <hr>

    <!-- INICIO:: CAMPOS EM MODO HIDDEN -->
    <input type="hidden" value="center" name="crop_X_Y" />
    <input  type="hidden" value="assets/publicidade/FURIOUS01/" name="stringDirPagina" />
    <input  type="hidden" value="128" name="parent_id" />
    <input  type="hidden" value="projectos_item" name="pagina_id"/>
    <input  type="hidden" value="inserir" name="tarefa" />
    <!-- FIM:: CAMPOS EM MODO HIDDEN -->

    <br/>
    <input type="submit" value="Enviar" />
</form>

This only happens when:

<input type="file" id="video" name="video" class="validate['required','video']" cols="100">

Exists!

var_dump( $_POST ), or $_FILES, print_r(), etc return nothing. I've trieed to create an array on the input of type "files", like img_p_child[], but nothing.

How to solve this ?

Thanks for taking your time!


I forgot to mention that, I trieed right now sending a image file in this second input field and works, but not with .FLV file. So I suspect there's a maximum permission, that I need to change on php.ini, if this is the case, I'm sorry! :X


Taken from php.net:

post_max_size affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. , and then checking if $_GET['processed'] is set.

memory_limit sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.

That being said, you need to change some things in your php.ini to allow larger uploads:

upload_max_filesize = 10M;
post_max_size = 20M;
memory_limit = 18M; 

Add the below to your .htaccess file in the you root directory.

php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 18M 

Obviously, these sizes will vary based on your needs. Here is a nice article on increasing your upload size.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜