0

Domain = benchmarkstudio.biz

Dedicated Hostgator Server

PHP Version 5.4.45

Can check the info from the below link. https://benchmarkstudio.biz/phpinfo.php

Issue I have created a test form in the below link where it uploads the attached file in the directory given and prints the message. https://benchmarkstudio.biz/portal/upload-test/upload.php

Note It is an open link so my dev community can try it too.

When I try files less than 10MB it gets successfully uploaded. But when I try files larger than 20MB it gives me

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster@benchmarkstudio.transdata.biz to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.**

(I can't find any error logs related to this.)

Although php.ini settings are:

max_execution_time = 300
max_input_time = 60
max_input_vars = 1000
memory_limit = 128M
post_max_size = 32M
session.gc_maxlifetime = 1440
upload_max_filesize = 64M

upload.php code is below

<form name="form" method="post" action="upload_file.php" enctype="multipart/form-data" >
<input type="file" name="my_file" /><br /><br />
<input type="submit" name="submit" value="Upload"/>
</form>

upload_file.php code is below

<?php
if (($_FILES['my_file']['name']!="")){
// Where the file is going to be stored
    $target_dir = "upload/";
    $file = $_FILES['my_file']['name'];
    $path = pathinfo($file);
    $filename = $path['filename'];
    $ext = $path['extension'];
    $temp_name = $_FILES['my_file']['tmp_name'];
    $path_filename_ext = $target_dir.$filename.".".$ext;
 
    // Check if file already exists
    if (file_exists($path_filename_ext)) {
        echo "Sorry, file already exists.";
    }else{
        move_uploaded_file($temp_name,$path_filename_ext);
        echo "Congratulations! File Uploaded Successfully.";
    }
}
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    Is there any reason you are using such an outdated version of PHP? I'm not saying it's relevant, it just seems a strange choice. – droopsnoot Mar 17 '22 at 09:05
  • I believe this is an encoding issue - the file to upload is base64-encoded which makes it larger, then it has various headers and separators added in, all of which could take a 20Mb file above your post_max_size. – droopsnoot Mar 17 '22 at 09:15
  • 1
    Also, as `upload_max_size` is the maximum size of each individual upload, and `post_max_size` is the maximum size of all of them, why is your post_max_size smaller than your upload_max_size? – droopsnoot Mar 17 '22 at 09:16
  • Also this final part of the error report `Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.` Makes me think its a seperate issue and related to a badly coded ErrorDocument [See the Docs](https://httpd.apache.org/docs/2.4/mod/core.html#errordocument) – RiggsFolly Mar 17 '22 at 09:20
  • In some case (such as if you use PHP FPM), you may need to increase [configuration in Apache](https://www.howtoforge.com/apache2-mod_fcgid-http-request-length-exceeds-maxrequestlen). For more configurations, please [read the document on Apache website](https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidmaxrequestlen). – vee Mar 17 '22 at 10:02
  • @droopsnoot yes its an outdated version and needs to be upgraded but firstly, I want to solve this issue. post_max_size is now 512M and upload_max_filesize = 256M now. Thank you for the suggestion. Still, the issue is there. – BenchMark IT Support Mar 17 '22 at 10:21

0 Answers0