Can't change error page or 504 Gateway Timeout

In the software I developed the admin can send a XLS file that is read and interpreted by the PHP and add some data to the database. Usually this file has 1500 lines and results in more than 7000 rows in the database. But, in the middle of the process I receive a 504 error.

After the error, if I look at the database there is still a process adding row to it, and after some time every data is inserted at the database.

I already tried to create a phprc file with the following lines, but the problem isn’t solved yet.

max_execution_time = 600 max_input_time = 600

The software is already being used, so I tried to change the error page explaining the situation, but it isn’t working.

This is my .htaccess:

[code]# Turn on the RewriteEngine
RewriteEngine On
Options +FollowSymLinks +Includes
Options -Indexes
IndexIgnore /


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index.php|images|robots.txt)

RewriteRule . index.php?/$0 [L][/code]

If I add the following lines, it works for the 404, but not for the 504.

ErrorDocument 404 "error ..." ErrorDocument 504 "error ..."

Then, if i change it to:

ErrorDocument 404 /home/MyUser/ ErrorDocument 504 /home/MyUser/
It does not work for any of the errors.

I need:
[]Get rid of the 504 error
]or Change the error page

The 504 error appears 4 or 5 minutes after I hit the upload button with the file already uploaded.