php.ini - 设置 upload_tmp_dir
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6034048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php.ini - setting upload_tmp_dir
提问by Tom
I have a page which allows users to upload photos - fairly standard php I think.
我有一个页面,允许用户上传照片 - 我认为相当标准的 php。
This works on the live server I've been using to date but I've recently set up php on my Mac and now the uploads have stopped working.
这适用于我迄今为止一直在使用的实时服务器,但我最近在我的 Mac 上设置了 php,现在上传已停止工作。
I'm guessing this is because the the upload_tmp_dir is not set properly in the php.ini file.
我猜这是因为 php.ini 文件中的 upload_tmp_dir 没有正确设置。
Does anyone know what I need to do?
有谁知道我需要做什么?
EDIT:
编辑:
Here's the error message that's output...
这是输出的错误消息...
Warning: imagejpeg(): Unable to open 'upload/thumbs/AL.jpg' for writing: Permission denied in /Users/tom/Sites/tombrennand/add.php on line 128 Warning: imagejpeg(): Unable to open 'upload/images/AL.jpg' for writing: Permission denied in /Users/me/Sites/mysite/add.php on line 135 Notice: Undefined variable: con in /Users/me/Sites/mysite/add.php on line 172 Warning: mysql_close() expects parameter 1 to be resource, null given in /Users/me/Sites/mysite/add.php on line 172
Warning: imagejpeg(): Unable to open 'upload/thumbs/AL.jpg' for writing: Permission denied in /Users/tom/Sites/tombrennand/add.php on line 128 Warning: imagejpeg(): Unable to open 'upload/images/AL.jpg' for writing: Permission denied in /Users/me/Sites/mysite/add.php on line 135 Notice: Undefined variable: con in /Users/me/Sites/mysite/add.php on line 172 Warning: mysql_close() expects parameter 1 to be resource, null given in /Users/me/Sites/mysite/add.php on line 172
So from that I think I need to set permissions on that folder. Any ideas?
因此,我认为我需要在该文件夹上设置权限。有任何想法吗?
采纳答案by webbiedave
Warning: imagejpeg(): Unable to open 'upload/thumbs/AL.jpg' for writing: Permission denied in /Users/tom/Sites/tombrennand/add.php on line 128
警告:imagejpeg():无法打开“upload/thumbs/AL.jpg”进行写入:第 128 行的 /Users/tom/Sites/tombrennand/add.php 中的权限被拒绝
You need to set the write permission on folder upload/thumbs
您需要设置文件夹的写权限 upload/thumbs
Since this is your personal computer, you can just cd
into folder upload
and then chmod 777 thumbs
in Terminal.
由于这是您的个人计算机,您可以直接cd
进入文件夹upload
,然后chmod 777 thumbs
进入终端。
回答by Ryan
Change the
改变
upload_tmp_dir = /tmp/whatever
entry in your php.ini
file. Ensure that this location is writable by the appropriate user/group.
您的php.ini
文件中的条目。确保该位置可由适当的用户/组写入。
回答by ccyarm
I had the same problem. I did a move_uploaded_file() to a folder I knew IIS users have writing permissions then I unzip that file. By default my PHP.ini is using c:\windows\temp and even if I gave writing permissions to IIS users it wasn't working.
我有同样的问题。我对我知道 IIS 用户具有写入权限的文件夹执行了 move_uploaded_file(),然后解压缩了该文件。默认情况下,我的 PHP.ini 使用的是 c:\windows\temp,即使我向 IIS 用户授予了写入权限,它也无法正常工作。
回答by dtbarne
View your phpinfo in a new page to see what it is set to:
在新页面中查看您的 phpinfo 以查看它的设置:
<?php phpinfo(); ?>
If it isn't where you need it to be, you can edit it with your php.ini file.
如果它不在您需要的位置,您可以使用 php.ini 文件对其进行编辑。