I need to process a CSV file and create a new CSV file. In order to get a proof of concept, I placed the CSV on the server and was able to process it fine. Then I setup a form in order to allow the client to upload the file. I don't even want to store the file on my server, just have the user submit it via the form, process it and provide the new file for download. The problem I am running into is when I run the $_FILES["file1"] through my function, I get this error "Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes)". The file is only 3Kb. I don't get this error when I process the same file when it is located in my uploads/ directory. Here's the code I'm using.
the form
<table width="600px">
<form action="dataupload.php" method="POST" accept-charset="UTF-8" enctype="multipart/form-data" autocomplete="off" novalidate>
<tr>
<td width="20%">File #1</td>
<td width="80%"><input type="file" name="file1" id="file1" /></td>
</tr>
<tr>
<td>Submit</td>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</form>
</table>
the PHP code
function readCSV($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) ) {
$line_of_text[] = fgetcsv($file_handle);
}
fclose($file_handle);
return $line_of_text;
}
$csvFile1 = $_FILES["file1"];
$csv = readCSV($csvFile1);
Can anyone help me figure out how to fix this? If I can't do it without just uploading the file to the server, that's fine. I've also had a bit of trouble getting that to work, so I could use help in that case.
Thanks