Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Permission denied

LEGEND ,
Apr 30, 2008 Apr 30, 2008
Hi All,

In my test server environment (on my MAC), I have created an upload_test
folder in my Sites folder, one in my website root folder, and one in my
Home folder, but every time I attempt to upload an image to any, I get
an error like the one below:

Warning:
move_uploaded_file(/Users/brett/upload_test/Toyota_Corolla_91.jpg)
[function.move-uploaded-file]: failed to open stream: Permission denied
in /Users/brett/vhosts/test10/upload04.php on line 6

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
move '/private/var/tmp/phpYorkEc' to
'/Users/brett/upload_test/Toyota_Corolla_91.jpg' in
/Users/brett/vhosts/test10/upload04.php on line 6

I'm on a MAC running PHP 5.2.4, MySQL 5.0.24, I'm using Apache 1.3.41
which was pre-installed on my G5. The PHP/MySQL is a build from Marc
Liyanage which I installed from instructions in PHP for DW8. Everything
up until now has worked fine, but then I've never tried to upload using
PHP until now. This issue seems to be a Permission problem and, try as I
have, I cannot seem to get the correct permission to upload. In looking
at the Apache section in phpinfo() I see this:

Hostname:Port localhost:80
User/Group www(70)/70

and it makes me wonder if I don't have permission because I'm not logged
in as user www? I log in as brett and I am the administrator so why is
Apache setting www as the User. If that is the problem, how do I get
Apache to have me as the user?

TIA for any help.
TOPICS
Server side applications
471
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2008 May 01, 2008
Brett wrote:
> Hi All,
>
> In my test server environment (on my MAC), I have created an upload_test
> folder in my Sites folder, one in my website root folder, and one in my
> Home folder, but every time I attempt to upload an image to any, I get
> an error like the one below:
>
> Warning:
> move_uploaded_file(/Users/brett/upload_test/Toyota_Corolla_91.jpg)
> [function.move-uploaded-file]: failed to open stream: Permission denied
> in /Users/brett/vhosts/test10/upload04.php on line 6
>
> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
> move '/private/var/tmp/phpYorkEc' to
> '/Users/brett/upload_test/Toyota_Corolla_91.jpg' in
> /Users/brett/vhosts/test10/upload04.php on line 6
>
> I'm on a MAC running PHP 5.2.4, MySQL 5.0.24, I'm using Apache 1.3.41
> which was pre-installed on my G5. The PHP/MySQL is a build from Marc
> Liyanage which I installed from instructions in PHP for DW8. Everything
> up until now has worked fine, but then I've never tried to upload using
> PHP until now. This issue seems to be a Permission problem and, try as I
> have, I cannot seem to get the correct permission to upload. In looking
> at the Apache section in phpinfo() I see this:
>
> Hostname:Port localhost:80
> User/Group www(70)/70
>
> and it makes me wonder if I don't have permission because I'm not logged
> in as user www? I log in as brett and I am the administrator so why is
> Apache setting www as the User. If that is the problem, how do I get
> Apache to have me as the user?
>
> TIA for any help.

I have never used PHP before, or Apache, but when your browser is doing
the upload, the user is www, not you, the same way the IIS on Windows
has IUSR_MACHINENAME as the user, unless you set IIS to Authenticate first.

Sorry I couldn't be much more help!

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2008 May 01, 2008
.oO(Brett)

>In my test server environment (on my MAC), I have created an upload_test
>folder in my Sites folder, one in my website root folder, and one in my
>Home folder, but every time I attempt to upload an image to any, I get
>an error like the one below:
>
>Warning:
>move_uploaded_file(/Users/brett/upload_test/Toyota_Corolla_91.jpg)
>[function.move-uploaded-file]: failed to open stream: Permission denied
>in /Users/brett/vhosts/test10/upload04.php on line 6
>
>Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
>move '/private/var/tmp/phpYorkEc' to
>'/Users/brett/upload_test/Toyota_Corolla_91.jpg' in
>/Users/brett/vhosts/test10/upload04.php on line 6
>
>I'm on a MAC running PHP 5.2.4, MySQL 5.0.24, I'm using Apache 1.3.41
>which was pre-installed on my G5. The PHP/MySQL is a build from Marc
>Liyanage which I installed from instructions in PHP for DW8. Everything
>up until now has worked fine, but then I've never tried to upload using
>PHP until now. This issue seems to be a Permission problem and, try as I
>have, I cannot seem to get the correct permission to upload. In looking
>at the Apache section in phpinfo() I see this:
>
>Hostname:Port localhost:80
>User/Group www(70)/70
>
>and it makes me wonder if I don't have permission because I'm not logged
>in as user www?

Correct. Apache (and many other services and daemons as well) uses its
own user account, usually 'www', 'www-data', 'nouser' or something like
that.

>I log in as brett and I am the administrator so why is
>Apache setting www as the User.

That's the default behaviour.

>If that is the problem, how do I get
>Apache to have me as the user?

You could change it in the Apache config, but I wouldn't recommend it.

Instead you should make the upload directory writable for the server,
for example by changing its owner and group to the one Apache uses. You
could also try to chmod that directory to 0777, but _only_ on your own
local machine, never on a host, as you don't want such a diretory being
writable for everyone.

As a hint: On my own sites I usually have a directory 'var' with full
write access for the web server. In this directory I store session data,
temporary files, my own log and all that stuff. All other directories
are usually not writable for the server.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 01, 2008 May 01, 2008
LATEST
Thanks Guys. The problem on my test server was that I had not
established Write permission for Others, I only had Read. Once changed,
all went well.

Brett
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines