Re: Help with file upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bunmi, you need to understand Unix file permissions.

Because you are running as the web server 'user / group' that user needs permission to write to the directory you are specifying. In this case you are trying to circumvent filesystem access controls by writing directly to the root directory of the filesystem !

So you need to adjust your path to for example /home/ayserve/public_html/fu/uploads/

*** Then*** You need to adjust the permission on this directory to allow write access to the web server. You can do this from most FTP clients (dreamweaver has a plugin to adjust the permissions of the directory). It needs to be mode 660 or 666 for testing, you can tighten up the permissions later.

If you absolutely cant do this by FTP somehow, try using

chmod("/home/ayserve/public_html/fu/uploads/",100666);
.... execute your upload after extensive file type checks
chmod("/home/ayserve/public_html/fu/uploads/",100755);

To change it back again to a safe setting as soon as possible !

666 corresponds to user-group-everybody, rwx and 660 to rw (no execute permission). Finally, 755 allows owner rwx and others rx permission - execute permission needs to be set again afterwards to allow the web server to traverse (read) the directory again.

PS _ Can you remind me again how this is related to Databases in PHP, the topic of this list ;-)

Cheers - Neil.

At 06:25 16/10/2003 +0000, you wrote:
Message-ID: <20031016051103.20061.qmail@pb1.pair.com>
To: php-db@lists.php.net
Date: Thu, 16 Oct 2003 06:09:07 +0100
From: Bunmi Akinmboni <bunmi.akinmboni@ayserve.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Subject: Re:  Help with file upload

I used this code now:

if (is_uploaded_file($_FILES['ufile1']['tmp_name'])) {
move_uploaded_file($_FILES['ufile1']['tmp_name'],'./' . $_FILES['ufile1']['name']);


This is the reply I got:

Warning: move_uploaded_file(./ayservenet.jpg): failed to open stream: Permission denied in /home/ayserve/public_html/fu/fuprocess.php on line 6

Warning: move_uploaded_file(): Unable to move '/tmp/phpfJyDSw' to './ayservenet.jpg' in /home/ayserve/public_html/fu/fuprocess.php on line 6
ayservenet.jpg DONE Array ( [ufile1] => Array ( [name] => ayservenet.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpfJyDSw [error] => 0 [size] => 3030 ) )


I had experienced this also on Windows IIS now it is also coming on my Linux yet I have full access to the two servers.

Bunmi

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux