The Upload takes until it gives an error, only in Chrome!

0

upload in Chrome has taken a long time and gives error. He rarely sends successfully. In the status bar there is a percentage of sending and stopping percentage in 40% or 59% .

When I do this through Mozilla Firefox , it sends successfully and without delay.

The form is a multipart/form-data default, and the upload script on the next page is a PHP , also default.

Could you tell what might be happening?

    $file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000);
    $nomearquivo = "projetos_".$file_id.'.'.getExtension($_FILES["Filedata"]["name"]);
    $nomearquivo=str_replace(' ', '', $nomearquivo);
    $nomearquivo=retirar_acentos_caracteres_especiais($nomearquivo);
    $newname="comite_cientifico_etica_trabalhos/".strtolower($nomearquivo);
    $copied = copy($_FILES['Filedata']['tmp_name'], $newname);

    
asked by anonymous 19.04.2017 / 15:56

2 answers

0

Try the following:

In the form : Create a input[type=hidden, name=MAX_FILE_SIZE] with maximum size value in bytes

<input type="hidden" name="MAX_FILE_SIZE" value="10000000">

In the PHP ( php.ini ) configuration, define:

file_uploads = On
upload_max_filesize = 10M
max_file_uploads = 20
post_max_size = 10M
max_input_time = 3600

On the page that handles the file, in case of an error, request the information with print_r($_FILES) :

That will display something like:

Array
(
    [arquivo] => Array
        (
            [name] => Meu arquivo.ext
            [type] => 
            [tmp_name] => 
            [error] => 2
            [size] => 0
        )

)

In this case, the value 2 means that the file exceeds the limit defined in MAX_FILE_SIZE in HTML form .

    
19.04.2017 / 16:57
0

Maybe you need to create the temporary :

$nome_temporario=$_FILES["arquivo"]["tmp_name"];

Then pass the filename to uniqid(md5(rand()));

Generates a unique identifier, based on the current time in millionths of a second. The Prefix can be used if you generate identifiers on multiple servers simultaneously, perhaps this is the detail in the delay.

$nome_real=$_FILES["arquivo"]["name"];
$nome_real = uniqid(md5(rand()));
copy($nome_temporario,"arquivos/$nome_real.pdf");

Then you make the copy of the temporary to destination folder. Without creating the path together. Just make the copy indicating the path and the new name.

    
19.04.2017 / 16:52