Upload file error 500

I am trying to upload a file to an IIS based server. here is my code: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); //ini_set('error_log','/httpdocs/error_log'); echo "

I am trying to upload a file to an IIS based server. here is my code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
//ini_set('error_log','/httpdocs/error_log');
echo "upload_max_filesize: " . ini_get ("upload_max_filesize"). "<br>";
echo "post_max_size: " . ini_get ("post_max_size"). "<br>";
echo "memory_limit: " . ini_get ("memory_limit"). "<br>";
echo "max_file_uploads: " . ini_get ("max_file_uploads"). "<br>";
echo "max_execution_time: " . ini_get ("max_execution_time"). "<br>";
echo "max_input_time: " . ini_get ("max_input_time"). "<br>";
echo "file_uploads: " . ini_get ("file_uploads"). "<br>";
echo "default_socket_timeout: " . ini_get ("default_socket_timeout"). "<br>";
echo "<br>";
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?>
<html>
<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

I used to get this error when i try to upload a file greater than 13MB:

Server Error

500 — Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.

then i added the error_reporting and i got this:

Network Error (tcp_error)

A communication error occurred: «Can’t send more» The Web Server may
be down, too busy, or experiencing other problems preventing it from
responding to requests. You may wish to try again at a later time.

For assistance, contact your network support team.

this is the settings:

upload_max_filesize: 20M

post_max_size: 128M

memory_limit: -1

max_file_uploads: 20

max_execution_time: 50000

max_input_time: 50000

file_uploads: on

default_socket_timeout: 6000

this is the web.config file:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    WindowsMicrosoft.NetFrameworkvx.xConfig 
-->
<configuration>
  <!--
    <configSections>
      <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
          <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
            <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          </sectionGroup>
        </sectionGroup>
      </sectionGroup>
    </configSections>  
-->
  <appSettings />
  <system.web>
    <httpRuntime 
        executionTimeout="9000" 
        maxRequestLength="65536" 
        useFullyQualifiedRedirectUrl="false" 
        minFreeThreads="8" 
        minLocalRequestFreeThreads="4" 
        appRequestQueueLimit="1000" 
        enableVersionHeader="true" 
    />
    <customErrors mode="On" />
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        -->
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
    <authentication mode="Forms" />
    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </controls>
    </pages>
    <httpHandlers>
      <remove verb="*" path="*.asmx" />
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <sessionState timeout="2880" />
  </system.web>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5" />
        <providerOption name="OptionInfer" value="true" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>
  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <security>
        <requestFiltering>
           <requestLimits maxAllowedContentLength="2147483648" />
        </requestFiltering>
    </security>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="ScriptHandlerFactory" />
      <remove name="ScriptHandlerFactoryAppServices" />
      <remove name="ScriptResource" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

I accessed the server remotely and tested it the response was:

PHP Warning: POST Content-Length of 9202605 bytes exceeds the limit
of 8388608 bytes in Unknown on line 0

How can i fix this problem?

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

nekooee opened this issue

May 9, 2018

· 14 comments

Comments

@nekooee

when I try upload images larger than 2MB, I get the following error message:

server responded with 500 code

in header:
Request URL: http://mydomain.com/filemanager/upload
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:80
Referrer Policy: no-referrer-when-downgrade

my confog and php.in is:
lfm.php:
‘max_image_size’ => 50000,
‘max_file_size’ => 50000,
php.ini:
upload_max_filesize=500M
post_max_size=500M
max_execution_time=900
memory_limit=256M
max_input_time=900

please help me :(

@FreedomKnight

what kind http server you use?
if you use nginx, maybe you need to set client_max_body_size.
if you use apache, you should set upload_max_filesize, post_max_size,

@nekooee

thank you. I use apache and set in php.ni «upload_max_filesize=500M , post_max_size=500M» but get error when upload images larger than 2MB.
I test in my host and in local. This problem exists in both!
I guess this problem is not in php.ini settings and is related to the file-manager.
I Need to help….

@nekooee

how to I test it without Ajax? An error may be displayed without ajax.

I used thid form:

<form action="http://mydomain.com/filemanager/upload" role="form" id="uploadForm" name="uploadForm" method="post" enctype="multipart/form-data" class="dropzone">
        <input type="hidden" name="working_dir" id="working_dir" value="/shares">
        <input type="hidden" name="type" id="type" value="image">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="file" name="file" id="file">
        <input type="submit">
</form>

get this message:
[«You must choose a file!»]

@nekooee

I change name and id from file to attachment. now upload form work. I tested a 10MB file , But the file could not be uploaded like AJAX, and displays the following error:

This page isn’t working
www.mydomain.com is currently unable to handle this request.
HTTP ERROR 500

please help me :(

@nekooee

I found the problem. The problem is exactly with this part of the code:

 if (parent::fileIsImage($file) && !in_array($file->getMimeType(), ['image/gif', 'image/svg+xml'])) {
                // Handle image rotation
                Image::make($file->getRealPath())
                    ->orientate() //Apply orientation from exif data
                    ->save($new_file_path);

                // Generate a thumbnail
                if (parent::imageShouldHaveThumb($file)) {
                    $this->makeThumb($new_filename);
                }
            } else {

Exactly this part:

  Image::make($file->getRealPath())
                    ->orientate() //Apply orientation from exif data
                    ->save($new_file_path);

when I remove this part, image upload successful but thumb is not created.
Why does this part of the code give error 500 for big photos?

@nekooee

I add this code to uploadController.php:

error_reporting(E_ALL);
ini_set("display_errors", 1);

and get this error :

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 21844 bytes) in C:testprojecttestProjectvendorinterventionimagesrcInterventionImageGdDecoder.php on line 136

What should I do?

@nekooee

I change memory_limit from 256M to 500M and my problem sloved!
👍

@nekooee

A 500M memory is great for image rotation of a 11M photo. Most hosts have a memory limit of up to 250 MB. WordPress without problems with 250 MB of memory.
Please optimize the resizing code.This is a huge constraint for our customers!
Many coders have reported that they use a lot of RAM and this is not acceptable for hosting. sample:
Intervention/image#781
It’s best to use another way to manage images.

@streamtw

Thank you @nekooee , we will keep this in mind.

@ghost

Hi, I got the same problem laravel-filemanager::lfm.error invalid
I have installed exif and fileinfo on my server.

I don’t found another solution :/.

Thanks.

@streamtw

@hanabalonch please check exception messages in storage/logs/laravel.log. If you need further discussions, please open a new issue.

I have added summary of this issue to our wiki, closing issue.

@djilali19

Hello,

thanks @nekooee I had the same problem, this last was solved by increasing the memory caused by Intervention / image

@Mahdi4a

i’v got the same problem i changed
my config and php.in is:
lfm.php:
‘max_image_size’ => 50000,
‘max_file_size’ => 1000000,
php.ini:
upload_max_filesize=1024M
post_max_size=1024M
max_execution_time=900
memory_limit=1024M
max_input_time=900

and i also change timeout in
Dropzone.options.uploadForm = {
paramName: «upload[]», // The name that will be used to transfer the file
uploadMultiple: false,
parallelUploads: 5,
timeout:1200000,

but it does’nt work i can’t upload file higher than 100m
how can i fix this?

@jeamado

Disable ModSecurity in cPanel and try

  • #1

I am using WHM 11.34.1 (build 7) on a vps running centos 5.3. I have created an account and uploaded a website to it. When I upload a file using PHP file the server lays out error 500.

I have checked the file permissions but nothing so far.I have no idea why the access log is not being written to.

CGI/FastCGI

I have done more checks on it and it seems like the file is being uploaded successfully however when the script that moves it is called, meaning when the form url is called I am getting error 500.

This is really strange.

Last edited: Feb 21, 2013

  • #2

When I upload a file using PHP file the server lays out error 500.

What does this mean? Can you be more specific?

  • #3

The upload starts and when the file gets submitted to PHP script that handles moving the file, I get the error 500. The script that handles the upload is located on on same page as the script that handles moving the file.

  • #4

Is the server running SuPHP?

  • #5

I have looked for mod_suphp in phpinfo() and there are no traces for it. However I have noticed that the directory permissions were named after the user account that I created using cpanel.

  • #6

I have looked for mod_suphp in phpinfo() and there are no traces for it. However I have noticed that the directory permissions were named after the user account that I created using cpanel.

Look what is the «Server API» in phpinfo.

  • #8

I have done more checks on it and it seens like the file is being uploaded successfully however when the script that moves it is called, meaning when the form url is called I am getting error 500.

  • #9

Sounds like you are not running SuPHP to me.

How large is the file you’re uploading?

  • #10

Means you use suPHP, and there should not be problems with file/directory rights if owner/group is the cPanel user and files are 644 and directories 755.

— — — Updated — — —

Sounds like you are not running SuPHP to me.

Really?
All our servers run suPHP and Server API = CGI/FastCGI.

  • #11

Well:

…the file is being uploaded successfully however when the script that moves it is called, meaning when the form url is called I am getting error 500.

That’s what that sounds like to me.

  • #12

Well:

That’s what that sounds like to me.

Or the script requires a PHP module that is not installed, or the script runs out of memory, or the script reaches the PHP max_execution_time, or the script is killed by CSF or similar, or there is a .htaccess problem, or 1 of 100 other different reasons.

Error 500 is a generic error message. Without checking the Apache error logs (/usr/local/apache/logs/error_log), any suggestions are basically guesswork.

Last edited: Feb 21, 2013

  • #13

I have found the problem. My initial problem was that there was nothing written in the access error logs. I have finally managed to solve this. Apparently GD was not installed. I have recompiled PHP with GD and it worked like a charm.

Thanks for all of ya for trying to help. It was a pleasure.

  • #14

Or the script requires a PHP module that is not installed, or the script runs out of memory, or the script reaches the PHP max_execution_time, or the script is killed by CSF or similar, or there is a .htaccess problem, or 1 of 100 other different reasons.

Error 500 is a generic error message. Without checking the Apache error logs (/usr/local/apache/logs/error_log), any suggestions are basically guesswork.

‘Sounds like’, is guesswork. Nothing more. Thank you for straightening me out though. You are correct, it could be 1 of 1000 things. And, with no mention of trying to upload images in this thread:

..Apparently GD was not installed.

We only had 999 more reasons to go, to figure it out. We were almost there! :p

Понравилась статья? Поделить с друзьями:
  • Upload failed please try again later geometry dash как исправить
  • Upload error тильда
  • Upload error саундклауд
  • Upload error tilda
  • Upload error please try again later перевод