PHP fopen (): File name cannot be an empty reason getRealPath return false

I am developing a Laravel project on Windows 10 locally using Laragon

PHP Version: 7.1.8 64bit NTS

related php.ini that I know

post_max_size = 8M

file_uploads = On


Source:

// if no image uploaded
if (!$request->hasFile('profile_picture')) 
throw new \Exception("No image found");

// get uploaded image
$image = $request->file('profile_picture');

// store to storage/app/users/
Storage::putFileAs('users', $image ,auth()->id());

enter image description here

In my opinion, this is a problem with the server configuration, maybe a problem with php.ini,

but I am not familiar with the server setup, and there are not many topics related to this problem in this thread.

I know the cause of the problem, but I do not know how to solve it.

0
source share
2 answers

Are you sure that the user who starts the user of the web server process has RW (read / write) access to the Windows TEMP Directory? If not, you will definitely fail!

- PHP TEMP Dir / .

php.ini .

upload_tmp_dir= 'PATH'

, "PATH", - /.

- - , - . .

+2

2 , , , . PHP-TS (Thread Safe) , .

PHP-NTS (Non Thread Safe), , NTS TS

PHP 7.1.7 64- TS TS

PHP 7.1.8 64bit NTS NTS

, , temp,

NTS C:\Windows\Temp,

, PHP realPath ( ), realPath false

TS C:\Users\YQuan\AppData\Local\Temp,

, realPath

  • , Windows

  • upload_tmp_dir php.ini "C:\Users\{_}\AppData\Local\Temp",

    .

0

Source: https://habr.com/ru/post/1683457/


All Articles