This topic is locked

Unable to create file in ...

1/31/2025 9:25:06 PM
PHPRunner Tips and Tricks
Admin

A few of our customers reported that after PHP update on the server they are not able to upload files. Upload breaks with "Unable to create file in ..." error message where ... points to the folder where files should be stored.

After some troubleshooting we found out that the following:

PHPRunner uses fopen() function with mode 'x' to ensure that uploaded file is saved under a unique name on the disk.
If the file with the given name already exists, it should return false, otherwise it should create a file and return a file handle.
This is documented in the manual:
https://www.php.net/manual/en/function.fopen.php

Somehow its behavior was different on customer's web server. The function creates a file, but returns false, so PHPRunner thinks it's unable to create a unique filename and fails. We don't know why this is happens, it might be a bug in PHP, in a Linux library, or, the most probable, some weird misconfiguration or security plugin installed on the web server.

We suggested to take this info to the web hosting company and here is the response from the customer:

Problem solved.
The PHP version used in the datacenter was the native version 8.2 distributed by cPanel. They switched to the alt-php82 version (version distributed by CloudLinux) and it now works correctly.
We therefore believe that this is indeed a bug introduced in the 8.2 version by cPanel. They will report the bug.
Thank you for pointing us in the direction to resolve the issue.
S
schaet 2/21/2025

Hello,
I am too facing this issue, however it is on my local LAMP stack. I am using PHP version 8.0.30. Is Is there any solution/workaround or do I need to install a different version of PHP (assuming alt-php82 is the one to go with?)

Admin 2/23/2025

It is hard to tell if this is the same issue or something else like missing permissions on the files folder. That specific error that a few of our customers encountered was related to PHP 8.2 distributed via cPanel.

G
GMO 3/7/2025

MySql 80 and Php 8.2

I was having same issue, Cpanel WHM control panel >> In Imunify 360, the "allow/ignore list", I added the path to "phpfunctions.php" >> Rule: Report black hash triggering >> Rules to ignore

Fixed the issue. " Unable to create file in"

Php Runner is a great Php generator. Awesome Software.

Thanks for great support