snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.2k stars 3.2k forks source link

Unable to Upload Temporary Files - PHP Warning on IIS Hosting #15452

Open mrraindrop555 opened 2 months ago

mrraindrop555 commented 2 months ago

Debug mode

Describe the bug

I am hosting a Snipe-IT application on IIS and encountered an issue when attempting to upload temporary files (e.g., images). The relevant directory C:\Windows\Temp has the correct permissions set for the IUSR, but the file upload fails with the following error:

PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0

Error Logs: Here’s what I found in the log file: `[2024-09-05 05:23:43] production.ERROR: Symfony\Component\Mime\Exception\InvalidArgumentException: The "" file does not exist or is not readable. in D:_My_Folders\Applications\Folders\SnipeIT\vendor\symfony\mime\FileinfoMimeTypeGuesser.php:44 Stack trace:

0 D:_My_Folders\Applications\Folders\SnipeIT\vendor\symfony\mime\MimeTypes.php(123): Symfony\Component\Mime\FileinfoMimeTypeGuesser->guessMimeType('')

...

[2024-09-05 05:23:43] production.ERROR: The "" file does not exist or is not readable. {"userId":1,"exception":"[object] (Symfony\Component\Mime\Exception\InvalidArgumentException(code: 0): The \"\" file does not exist or is not readable. at D:\_My_Folders\Applications\Folders\SnipeIT\vendor\symfony\mime\FileinfoMimeTypeGuesser.php:44) [stacktrace]

0 D:\_My_Folders\Applications\Folders\SnipeIT\vendor\symfony\mime\MimeTypes.php(123): Symfony\Component\Mime\FileinfoMimeTypeGuesser->guessMimeType('')

... `

Additional Information:

Reproduction steps

  1. Host Snipe-IT on IIS.
  2. Set permissions for IUSR on the temporary directory (C:\Windows\Temp).
  3. Attempt to upload an image via the app.

Expected behavior

The application should be able to create and handle temporary files successfully, allowing the image upload process to complete without errors.

Screenshots

No response

Snipe-IT Version

7.0.11

Operating System

Windows

Web Server

IIS

PHP Version

8.3.4

Operating System

Windows

Browser

Chrome, Edge

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

The debug interface and the application disappear and only this line of error is displayed on the screen.

`PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0`

Additional context

No response

welcome[bot] commented 2 months ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

snipe commented 2 months ago

That's always a permissions issue. If that's where you want your temp directory to be, make sure your php.ini has upload_tmp_dir=C:\Windows\Temp.

We're not really IIS experts here, but this might help: https://stackoverflow.com/questions/16488834/unable-to-create-a-temporary-file-while-uploading

Stack Overflow
Unable to create a temporary file while uploading
While trying to upload a file using a form and PHP/IIS 7, I get this message: PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0 My form: <form action="