Problemas comuns

O item MAX_FILE_SIZE não pode especificar um tamanho de arquivo com tamanho maior do que o especificado no php.ini em upload_max_filesize. O padrão é 2 Megabytes.

Se o limite de memória esta ativado, um maior memory_limit pode ser necessário. tenha certeza de estabelecer um memory_limit grande o suficiente.

Se max_execution_time for muito pequeno, a execução do script pode ultrapassar o limite de tempo. Tenha certeza de estabelecer um max_execution_time grande o suficiente.

Nota: max_execution_time somente afeta o tempo de execução do script em sí. Qualquer tempo gasto com atividades que aconteçam fora da execução do script como chamadas de sistema usando system(), a função sleep(), pesquisas em banco de dados, tempo gasto pelo processo de carregar(upload) um arquivo, etc. nâo é incluso na hora de determinar o lmite de tempo que o script esta sendo executado.

Aviso

max_input_time define o tempo máximo em segundos, que é permitido ao script receber entradas, isto inclui uploads de arquivos. Para um arquivo grande ou multiplos arquivos, ou usuários em conexões lentas, o padrão de 60 segundos pode ser ultrapassado.

Se post_max_size for muito pequeno, arquivos grandes não poderão ser carregados. Tenha certeza de estabelecer post_max_size grande o suficiente.

Não validar o arquivo que você esta operando pode permitir que os usuários acessem informações sensíveis em outros diretórios.

Por favor note que o CERN httpd aparenta cortar tudo iniciando após o primeiro espaço do header content-type que ele recebe do cliente. Se for este o caso, CERN httpd não irá suportar o upload de arquivos.

Devido ao grande número de estilos de listagem de diretórios nós não podemos garantir que arquivos com nomes exóticos(como que contém espaço) sejam manuseados corretamente.

Um desenvolvedor não deve misturar campos de entrada e campos de upload de arquivo na mesma variável de formulário (usando um nome de campo como foo[]).

add a note add a note

User Contributed Notes 10 notes

up
2
Nirmal Natarajan
4 years ago
If using IIS 7.0 or above, the Request Filtering is enabled by default and the max allowed content length is set to 30 MB.

One must change this value if they want to allow file uploads of more than 30 MB.

Sample web.config entry:

<configuration>
    </system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="314572800"/>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

The above setting will allow 300 MB of data to be sent as a request. Hope this helps someone.
up
1
tjaart at siam-data-services dot com
9 years ago
Took me a while to figure this one out...

I think this is actually a header problem, but it only
happens when doing a file upload.

If you attept a header("location:http://...) redirect after
processing a $_POST[''] from a form doing a file upload
(i.e. having enctype="multipart/form-data"), the redirect
doesn't work in IE if you don't have a space between
location: & http, i.e.
header("location:http://...)  vs
header("location: http://...)

===================================
<?php
if ($_POST['submit']=='Upload') {
   
// Process File and the redirect...
   
header("location: http://"..."/somewhere.php");
    exit;
}
?>
<html><head></head><body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="20000">
    Your file: <input name="filename" type="file">
    <input name="submit" type="submit" value="Upload">
</form>
</body></html>
===================================

This only happens if all of the following are true:
header("location:http://...) with no space
Form being processed has enctype="multipart/form-data"
Browser=IE

To fix the problem, simply add the space.

Hope this helps someone else.
up
1
amalcon _a_t_ eudoramail _d_o_t_ com
10 years ago
Note that, when you want to upload VERY large files (or you want to set the limiters VERY high for test purposes), all of the upload file size limiters are stored in signed 32-bit ints.  This means that setting a limit higher than about 2.1 GB will result in PHP seeing a large negative number.  I have not found any way around this.
up
1
morganaj at coleggwent dot ac dot uk
11 years ago
Here is another that may make your upload fall over.  If you are using Squid or similar proxy server make sure that this is not limiting the size of the HTTP headers. This took me weeks to figure out!
up
1
sebastian at drozdz dot ch
11 years ago
It's important that the variable 'open_basedir' in php.ini isn't  set to a directory that doesn't not includes tempupload directory
up
0
dg at artegic dot de
4 years ago
In case of non-deterministic occurence of the UPLOAD_ERR_PARTIAL error:  The HTTPD (e.g. Apache) should respond with a 'Accept-Ranges: none' header field.
up
0
anders jenbo pc dk
7 years ago
A responce to admin at creationfarm dot com, Mac OS X and Windows running on a NTFS disk also uses a multi stream file system. Still only the data stream in transfared on http upload. It is preferable to pack Mac OS X files in .dmg files rathere then zip but the avarage user will find zip much easir and they are supported on more platforms.
up
0
tomcashman at unitekgroup dot com
11 years ago
For apache, also check the LimitRequestBody directive.
If you're running a Red Hat install, this might be set in /etc/httpd/conf.d/php.conf.
By default, mine was set to 512 KB.
up
0
admin at creationfarm dot com
11 years ago
The macintosh OS (not sure about OSx) uses a dual forked file system, unlike the rest of the world ;-). Every macintosh file has a data fork and a resource fork. When a dual forked file hits a single forked file system, something has to go, and it is the resource fork. This was recognized as a problem (bad idea to begin with) and apple started recomending that developers avoid sticking vital file info in the resource fork portion of a file, but some files are still very sensitive to this. The main ones to watch out for are macintosh font files and executables, once the resource fork is gone from a mac font or an executable it is useless. To protect the files they should be stuffed or zipped prior to upload to protect the resource fork.

Most mac ftp clients (like fetch) allow files to be uploaded in Macbinhex, which will also protect the resource fork when transfering files via ftp. I have not seen this equivilent in any mac browser (but I haven't done too much digging either).

FYI, apple does have an old utility called ResEdit that lets you manipulate the resource fork portion of a file.
up
-1
oliver dot schmidt at drehsinn dot de
7 years ago
If you want to use open_basedir for securing your server (which is highly recommended!!!) remember to add your tmp dir to the open_basedir value in php.ini.

Example: open_basedir = <your htdocs root, etc...>:/tmp

(Tested on gentoo Linux, Apache 2.2, PHP 5.1.6)
To Top