rober0826
By:
rober0826

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

November 23, 2016 151 views
PHP

How can i fix this im uploading excel to my website then this shows up i made a virtual server and it works fine but When online it does not work

2 Answers
ryanpq MOD November 23, 2016
Accepted Answer

With a PHP application, when encountering a 500 error on a file upload these are the first things to check:

1.) Is the directory where the uploaded file is being placed owned by www-data (Debian/Ubuntu) or apache (CentOS)? If the web server process does not have permission to copy the file from it's temporary location to the upload directory it can cause issues.

2.) Is the file larger than the maximum size? In your php.ini (with apache this is /etc/php5/apache2/php.ini) look for upload_max_filesize and post_max_size and make sure they are larger than any file you expect the form to receive.

3.) It is also possible that the error is occurring after the file upload if any post-upload processing is being done. If your script is doing any processing of an excel file certain libraries or other tools may be required.

You can check for any errors in the error log. When a 500 error is returned additional details of the error should be recorded there. If you're running Apache this can be found in /var/log/apache2/error.log

  • it has a long error log what should i do with it sorry i'm just a newbie

    • The easiest way to get the specific error you need without digging through the logs would be to:

      1.) Log into your droplet and run the command:

      tail -f /var/log/apache2/error.log
      

      This will have the contents of the error log stream to your console, automatically showing any new entries as they are created.

      2.) attempt your file upload again.

      You should now have just a few lines (including the relevant ones) displayed in your console/ssh client.

      • When done you can use ctrl+c to exit out of the tail command

        • Thank you will try to reupload my website first.

        • Class 'ZipArchive' not found in /var/www/html/thesis/import/PHPExcel/Reader/Excel2007.php:94\nStack trace:\n#0 /var/www/html/thesis/import/PHPExcel/IOFactory.php(268): PHPExcelReaderExcel2007->canRead('import.xlsx')\n#1 /var/www/html/thesis/import/PHPExcel/IOFactory.php(191): PHPExcelIOFactory::createReaderForFile('import.xlsx')\n#2 /var/www/html/thesis/import/import.php(155): PHPExcelIOFactory::load('import.xlsx')\n#3 {main}\n thrown in /var/www/html/thesis/import/PHPExcel/Reader/Excel2007.php on line 94, referer:

          still getting this error

          • I've got a solution for you on that one. Your php installation does not have the zip extension needed for the code you're running. This can be easily fixed.

            On Ubuntu 16.04, run:

            sudo apt-get update;
            sudo apt-get install php7.0-zip;
            sudo service apache2 restart;
            

            On Ubuntu 14.04 and older:

            sudo apt-get update;
            sudo apt-get install php5-zip;
            sudo service apache2 restart;
            

i've already done that problem still persist

Have another answer? Share your knowledge.