0

i have the following code, just for debug purpose:

 <?php
    if ($_FILES['productsFile']) {
    ini_set("display_errors","on");
    error_reporting(E_ALL);
    ini_set('max_input_time ', 600000);
    ini_set('memory_limit', '512M');
    ini_set('max_execution_time', '180');
    ini_set('post_max_size ', "250M");
    ini_set('upload_max_filesize ', "250M");
    setlocale( LC_ALL, 'en_US.UTF-8' );
    $fileName = "ecom_productImport_".time();
    move_uploaded_file($_FILES['productsFile']['tmp_name'], "myfoter/".$fileName) upload");

    $handle = fopen($fileName, "r");

    $start=0;
    unset($fileName);
    while (($data = fgetcsv($handle, 950000, ",")) !== FALSE) {
      // some code that use insert and update queries
    }
}

now when i run this code on a command line - it runs without a problem but when i run it from a webpage in get the Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

any variable that is setted inside the loop is unsetted and the sql queries does not take long. i really have no clue about why it's keeping hanging up.

my webserver is apache 2 and the php version is 5.3.8

sd1sd1
  • 1,028
  • 3
  • 15
  • 28
  • I see a trailing " at line 11 – Aurelio De Rosa Jul 01 '13 at 10:46
  • `move_uploaded_file($_FILES['productsFile']['tmp_name'], "myfoter/".$fileName) upload");` this is definitely not valid php code. – slash197 Jul 01 '13 at 10:47
  • replace the move_uploaded_file with `move_uploaded_file($_FILES['productsFile']['tmp_name'], "myfoter/".$fileName);` – Code Lღver Jul 01 '13 at 10:49
  • You cannot change `post_max_size` or `upload_max_filesize` from within PHP code. PHP will have already aborted the upload when your `ini_set()` statement runs. Additionally, a memory limit of 512 MB is quite a lot. In my experience, PHP can't always handle that. Not sure why you need that if you appear to read the file in 950,000 byte chunks. – Álvaro González Jul 01 '13 at 10:53
  • the move_uploaded_file works fine. Alvaro - it might be possible that the 950,000 is too small? – sd1sd1 Jul 01 '13 at 11:06
  • Why do you ask that? Do you really want your script to require 512MB of RAM? – Álvaro González Jul 04 '13 at 10:53

0 Answers0