Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

medabkari's avatar

Dev Server Shuts Down On File Upload

Hey everyone!

I'm having an issue with uploading files in Laravel applications, the issue is that whenever I upload a file and submit the form, the php artisan serve dev server shuts down with no errors logged in laravel.log file, and I don't know what could be causing the issue.

I checked php.ini settings responsible for file uploads and increased memory limits just in case, but the issue persisted. I tried uploading files in two more applications and got the same issue.

Has anyone encountered this issue before?

Thanks in advance for your assistance!

0 likes
1 reply
LaryAI's avatar
Level 58

It sounds like you're encountering an issue where the PHP built-in server (php artisan serve) is crashing when you attempt to upload a file. This can be caused by several factors, including PHP configuration settings, server limitations, or even bugs in the PHP built-in server itself.

Here are a few steps you can take to troubleshoot and potentially resolve this issue:

  1. Check PHP Configuration: Ensure that your php.ini settings are configured correctly for file uploads. Key settings to check include:

    • upload_max_filesize
    • post_max_size
    • memory_limit

    For example, you might want to set these values to something higher if you're dealing with large files:

    upload_max_filesize = 10M
    post_max_size = 12M
    memory_limit = 128M
    
  2. Use a Different Server: The PHP built-in server is not recommended for production use and can sometimes be unstable. Try using a more robust server like Apache or Nginx for your development environment. You can set up a local development environment using tools like XAMPP, WAMP, or Laravel Valet.

  3. Check for Errors: Since no errors are logged in laravel.log, try checking the PHP error log. The location of this log can be set in your php.ini file with the error_log directive. For example:

    error_log = /path/to/php-error.log
    
  4. Increase Execution Time: Sometimes, the server might be timing out during the file upload process. You can increase the max_execution_time in your php.ini file:

    max_execution_time = 300
    
  5. Check Disk Space: Ensure that your server has enough disk space to handle the file uploads. A lack of disk space can cause the server to crash.

  6. Debugging: Add some debugging statements in your Laravel controller to see if the request is being processed correctly. For example:

    public function upload(Request $request)
    {
        if ($request->hasFile('file')) {
            $file = $request->file('file');
            \Log::info('File upload started: ' . $file->getClientOriginalName());
            // Process the file upload
            \Log::info('File upload completed');
        } else {
            \Log::info('No file uploaded');
        }
    }
    
  7. Check for PHP Extensions: Ensure that all necessary PHP extensions for file uploads are enabled. Common extensions include fileinfo and mbstring.

  8. Update PHP and Laravel: Ensure that you are using the latest versions of PHP and Laravel, as bugs and issues are often fixed in newer releases.

If none of these steps resolve the issue, you might want to consider posting more details about your environment (PHP version, Laravel version, etc.) on the Laracasts forum for further assistance.

Here's a summary of the key points in code format for clarity:

; php.ini settings
upload_max_filesize = 10M
post_max_size = 12M
memory_limit = 128M
max_execution_time = 300
error_log = /path/to/php-error.log
// Laravel controller method
public function upload(Request $request)
{
    if ($request->hasFile('file')) {
        $file = $request->file('file');
        \Log::info('File upload started: ' . $file->getClientOriginalName());
        // Process the file upload
        \Log::info('File upload completed');
    } else {
        \Log::info('No file uploaded');
    }
}

By following these steps, you should be able to identify and resolve the issue causing your development server to shut down during file uploads.

Please or to participate in this conversation.