Nginx + PHP Centos 7 + Laravel 5.4 file upload

I'm using Virtualmin on my server for my clients. I try to upload a image file via html form with Laravel 5.4. I'm using Nginx to handle requests. Also, I have php 7.1.1. However, when I try to upload a file at the bottom of the screen there is a percentage bar and at the end of the upload I get this error page from Laravel:

getimagesize(/tmp/phpHRFIvJ.jpeg): failed to open stream: No such file or directory in Brush.php line 17 at HandleExceptions->handleError(2, 'getimagesize(/tmp/phpHRFIvJ.jpeg): failed to open stream: No such file or directory' ...

I have another server with the same setup without Virtualmin and it just works. What can be the issue? Or where should I update on my server.

Have a nice day.

Status: 
Closed (fixed)

Comments

Mostafa's picture
Submitted by Mostafa on Wed, 03/01/2017 - 14:35

Hello!

Could you create the following script on your website and run it?

<?php
echo ini_get("upload_tmp_dir");
echo touch ("/tmp/test.txt");
echo unlink("/tmp/test.txt");
?>

You should get :

/tmp11

which would mean that the upload_tmp_folder is set to /tmp and your website has read/write access to this folder

Hello thanks for quick reply! I got "11" that's all. I changed php.ini. set tmp_dir to /uploads. It now shows /uploads11 yet my error still says file not found.

Mostafa's picture
Submitted by Mostafa on Wed, 03/01/2017 - 15:03

OK so upload_tmp_dir value is not set for your website therefore your files are not uploaded to /tmp folder. You need to edit your php.ini file and set upload_tmp_dir value to /tmp To find out the path of php.ini file that you should edit you can use:

<?php phpinfo(); ?>

the path is shown as Loaded Configuration File

Hello again, I changed it to /uploads yet it still could not find the folder or file.

Hello again, I solved the issue with adjusting the path from my code. Probably, ubuntu and centos is different in file management (file extensions etc.) Now it works with some code changes and adding tmp folder to php.ini

Thanks so much for the help.

Assigned: Unassigned »
Status: Active » Closed (fixed)