Mattiman's avatar

AccessDeniedException in MimeTypeGuesser.php

Working on a file upload feature I'm encountering the following error:

AccessDeniedException in MimeTypeGuesser.php line 119: The file /tmp/phps7Q47C could not be accessed

Using Homestead on OS X. Guess it's some file permission issue, but since it's inside Homestead, how do I solve that? Where would /tmp be and how would you fix permissions on it?

0 likes
2 replies
mcordingley's avatar

/tmp is a fully-qualified path. It's the tmp folder within your file-system root. It's used as a temporary scratch space. Anything placed in there will automatically get deleted by your operating system after some time has passed. I think the trigger is that the last access or modification time reaches some threshold, like so many days old or something. Regardless, /tmp is unique among directories in that it can always be written to by any user. So, you are probably not experiencing any permissions issues.

As to the cause of your specific error, I have a suspicion about what's going on. Does this error happen when you call a function on the file object to get details about it? And, is this function call happening after you move the file to where it's supposed to go? If both of these are true, then what's happening is that the move operation removes the file from /tmp but does not update the file object's reference to the file. When you try to call whatever function it is, the object tries to open the file from its old location and then fails, since that file no longer exists.

Please or to participate in this conversation.