16

I'm simply using a html form to upload a file.

But I'm getting below error:

Notice: Unknown: file created in the system's temporary directory in Unknown on line 0

Here's my HTML:

<form name="import" method="post" action="CSVUpload" enctype="multipart/form-data">
    <input type="file" name="file" /><br />
    <input type="submit" name="submit" value="Submit" />
</form>

Here's the route:

$f3->route('POST|PUT @CSVUpload: /CSVUpload', 'GBD\Internals\Controllers\LeaveController->csvHandler');
$f3->route('GET /CSVUpload', 'GBD\Internals\Controllers\LeaveController->csv');

Here's my controller:

public function csv()
{
    $this->f3->set('content', 'leave/csvUploader.php');
    $template = new \View;
    echo $template->render('dashboard/layout.php');
}

public function csvHandler()
{
    $postvalue = $this->f3->get('POST.submit');
    if(isset($postvalue))
    {
        $fileReceived = $this->f3->get('POST.file');
        var_dump($fileReceived);
    }
}

I am using fat-free framework.

I found out that uploaded files are temporarily stored to upload_tmp_dir="C:\inetpub\temp".

What is wrong here??

Any help is very much appreciated. Thanks.

Amit Gupta
  • 2,771
  • 2
  • 17
  • 31
Azima
  • 3,835
  • 15
  • 49
  • 95

7 Answers7

15

This is not an error, this is a notice. See this request. Basically, it's just telling you that it has fallen back to the system's default temp dir, as opposed to something more specific that you have provided. You can override it to something more specific (like a temp dir specifically for this app) or disable notices via error_reporting(). I'd recommend the former.

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
7

Be sure that the directory you want to save something is writeable.

For example, in my case, it was a Concrete 5 directory that has to be writeable.

miken32
  • 42,008
  • 16
  • 111
  • 154
Serdar D.
  • 3,055
  • 1
  • 30
  • 23
  • For me the permissions of the folder were 776 and it still didn't work until I changed them to 777. For me it was not implicit that PHP required public execute on the directory but I guess it does. Also: "*it stopped crying*", that one cracked me up lol. – Silidrone Jan 02 '21 at 15:56
  • 2
    Please don't use permission 777. That's terrible security. Make the directory owned by the user that needs to use it and use restrictive permissions. – jlh Jun 04 '21 at 07:56
7

It also happens if your php.ini has wrong upload_tmp_dir path.

p.s. it may not be possible to disable it with error_reporting().

ViliusL
  • 4,589
  • 26
  • 28
2

If some still facing the same issue in Laravel and using XAMPP on localhost, this is how I fixed this.

  • Open php.ini and search for upload_tmp_dir
  • Make sure the path is correct.
  • If the path is something like upload_tmp_dir = "\xampp\tmp"
  • Change the path to an absolute path, for me it was upload_tmp_dir = "D:\xampp\tmp"

Happy coding :)

hassanrazadev
  • 626
  • 9
  • 15
  • Thanks, your solution make think, do I have temp directory in my PHP directory, which I didn't. – Nazari Apr 15 '23 at 05:25
1

After spending 3 hrs, I found that I had accidentally deleted the temp and tmp from my windows 10 env variable, by adding the path as follows, my issue was resolved

enter image description here

Kunal Rajput
  • 664
  • 1
  • 7
  • 21
0

In my case, make temp directory fixed my issue, for record via Laravel and Livewire you will get same message response with XHR request.

Open your PHP.ini file and set path and make that directory

upload_tmp_dir="C:\php\php-8.1.4\tmp"

Note: Livewire will not use that directory but the source issue which is PHP will be fixed and the Livewire let paths = retrievePaths(request.response && JSON.parse(request.response)) will work.

Nazari
  • 438
  • 1
  • 9
  • 20
0

Provide write permission to bootstrap/cache folder it will solve the issue

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 05 '23 at 14:40
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34638583) – Yogendra Jul 07 '23 at 08:29