I am doing a
curl -d @data.csv myserver.com
to POST Data to my linux server. Using laravel my routes will route the POST request to a function inside my Controller.php:
public function endpoint(Request $request)
{
$handle = $request->file('data.csv');
$use = fopen($request->file('data.csv'), "r");
}
Now the errorlog returns: [2021-06-24 15:44:55] production.ERROR: fopen(): Filename cannot be empty {"exception":"[object] (ErrorException(code: 0): fopen()
--> so the expected data.csv ist not arriving, the request seems to be empty. Of course, I googled the issue first. All answers online say this is due to wrong permissions on the folder where the uploaded file is temporarily stored, but where is that? Doing a
$temp_file = tempnam(sys_get_temp_dir(), 'Tux'); echo $temp_file;
echos /tmp/TuxWk8llX
which leads me to belive the default tmp directory is /tmp/. My php.ini says also that /tmp/ is this upload directory (see below). But doing an ls
on /tmp/ shows it has all permissions: drwxrwxrwt. 1 root root 57 Jun 24 13:28 tmp
So why is the request not coming through, any ideas? Thanks in advance, am really confused about by this! :)
PS: Might this ; sys_temp_dir = "/tmp"
in the php.ini cause the problem?
**php.ini config file**
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = /tmp
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 200M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
; Directory where the temporary files should be placed.
; Defaults to the system default (see sys_get_temp_dir)
; sys_temp_dir = "/tmp"