php ile büyük dosya yükleme sorunu

4 Cevap php

Ben bir sunucuya bir csv dosyası yüklemek gerekir. küçük dosyalar için çalışıyor ancak dosya 3-6 meg zaman onun değil çalışma.

$allowedExtensions = array("csv");
         foreach ($_FILES as $file) { 
            if ($file['tmp_name'] > '') { 
             if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { 

              die($file['name'].' is an invalid file type!<br/>'. '<a href="javascript:history.go(-1);">'. '&lt;&lt Go Back</a>'); 

             }
             if (move_uploaded_file($file['tmp_name'], $uploadfile)) {
                    echo "File is valid, and was successfully uploaded.\n";
                } else {
                    echo "Possible file upload attack!\n";
              }

             echo "File has been uploaded";



            } 

/ / Yükleme formu

 <form name="upload" enctype="multipart/form-data" action="<? echo $_SERVER['php_self'];?>?action=upload_process" method="POST">
                    <!-- MAX_FILE_SIZE must precede the file input field -->
                    <input type="hidden" name="MAX_FILE_SIZE" value="31457280" />
                    <!-- Name of input element determines name in $_FILES array -->
                    Send this file: <input name="userfile" type="file" />
                    <input type="submit" value="Send File" />
            </form>

Ben de htaccess bu ekledi

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

Nerede yanlış gidiyorum?

4 Cevap

$ HTTP_POST_FILES değer ['userfile'] ['error'] nedir? Buraya bir göz atın:

http://php.net/manual/en/features.file-upload.errors.php

Ayrıca, nedir bu ile:

if ($file['tmp_name'] > '') { 

Ben çok sağlıklı olduğunu sanmıyorum.

Kodunuzu sadece bazı öneriler

  • ($file['tmp_name'] > '') gibi bir şey olmalı ( ! empty($file['tmp_name']))
  • "olası dosya yükleme saldırısı" yankılanan kimseye yardımcı olmaz. Eğer olası bir saldırı olduğunu düşünüyorsanız, bir dosyaya kaydetmek.
  • Bir sabittir, yani $_SERVER['PHP_SELF'], çünkü formu eylem niteliği, $_SERVER['php_self'] harf olmalıdır.

Apache hata günlüklerini denetleyin ve hata olmalı?

. Htaccess php.ini üzerinde önceliğe sahiptir eğer php.ini dosyasını kontrol edin ve upload_max_filesize 3 MB daha yüksek ayarlanır var eğer görmek, bilmiyorum.

Yanlış hatırlamıyorsam eğer Debian php5 üzerinde varsayılan yükleme sınırı 2MB olduğunu, ama üzerinde çalışan hangi sistem emin değilim.

Eğer e.g. info.php ve put it in the same directory as your "problem php script". bir dosya oluşturmak durumunda da php değerlerini kontrol edebilirsiniz

The file content should look like this <?php phpinfo(); ?>

Bu give you all php relevant values referring to the directory you are in, o yardımcı olur umuyoruz.