-2

I am using Adobe flex to write 10Mb of array(containing integers) to a bin file(text file) using PHP. But I am unable to get the file, as the PHP is getting crashed each time I am trying to send the array.

Below is the PHP code, I am using to write an array to .bin file

$Text = $_POST["first"]; 
$arr = explode(",",$Text);
$myFile = "test1.bin";
$count=count(explode(",",$Text));
echo sizeof($arr);
$fh = fopen($myFile, 'a') or die("can't open file");
for($i=0;$i<sizeof($arr);$i++)
{
    $sd=pack(V,$arr[$i]); 
    fwrite($fh,"$sd");
}
fwrite($fh,$str);
fclose($fh);

The problem is in PHP code, as the array if successfully passed from flex, so that's why I am posting only PHP.

Please let me know, the alternate way or the correct way of working.

Thanks

open source guy
  • 2,727
  • 8
  • 38
  • 61
user1647017
  • 283
  • 1
  • 2
  • 14
  • If your array is that big, I would say processing it takes more time to PhP than the allowed timeout... Have you tried it with a smaller string ? – Laurent S. Apr 08 '13 at 12:18
  • 1
    What message are you getting on failure? – bubba Apr 08 '13 at 12:18
  • Yes, I have tried with smaller arrays, Its nicely saving into file. But when I tried to send big data, the output is either `Memory Exhausted `, or no response from script. I have prevented the script from displaying the error "Memory Exhausted" by adding `ini_set("memory_limit",-1))` but still there is no output – user1647017 Apr 08 '13 at 12:29

1 Answers1

0

Increase your post_max_size:
http://www.php.net/manual/en/ini.core.php#ini.post-max-size

By default it's 8M I think, increase it to like 15M or 20M.

Anyone
  • 2,814
  • 1
  • 22
  • 27
  • Where I need to write that line, as its showing error if I write start of the PHP – user1647017 Apr 08 '13 at 12:38
  • You have to change it either in your php.ini or add it to your .htaccess: http://stackoverflow.com/questions/1122418/changing-upload-max-filesize-on-php – Anyone Apr 08 '13 at 12:48