Jump to content

Archived

This topic is now archived and is closed to further replies.

arunvg

Giving permissions for PHP to write in folders

Recommended Posts

Hi Friends,

I am using [color=orange][color=blue]PHP5.1.6 with MYSQL5.0 and IIS6.0 (Windows 2003 Server)[/color][/color]as an environment for my project managament tool.
I have got some error in uploading files to that tool.
I was advised to check whether the folders have permissions for PHP to write into it.I have given the permission to folders (Properties-> Checking  the column for "Write"). but it is still not working. Is there any other methods to give permissions for PHP to write into that folders.
Pls help me. ???

Thanks
Arun :(

Share this post


Link to post
Share on other sites
If you'#re creating a file using fopen, you need to include "w+" e.g. to create the file "newfile.txt" use [code]<? fopen("newfile.txt", "w+"); ?>[/code]

Share this post


Link to post
Share on other sites
Thank you for your reply :).

The problem is that we have some existing folders and we have to give permissions for them.Can u give any suggestions.
Thanks
Arun

Share this post


Link to post
Share on other sites
Do you mean CHMOD?  If so you can use chmod('file path', permission ie 0777).
chmod('/opt/lampp/htdocs/hello/', 0777).  Sometimes this wont work on some servers so you have to use FTP to CHMOD it.

You can do something like this for FTP CHMOD
[code]
<?php
//Let's check if file is NOT writeable.
if (!is_writeable($file))
{
//Connect to FTP and login
$ftp_connect = ftp_connect($ftp_url);
if (!$ftp_connect)
die('Can\'t connect');

$ftp_login = ftp_login($ftp_connect, $ftp_user, $ftp_pass);
if(!$ftp_login)
die('Can\'t login');

//FTP CHMOD
if (!ftp_site($ftp_connect, 'CHMOD 0777' . $file))
ftp_site($ftp_connect, 'CHMOD 0755' . $file);
else
echo 'File not writeable';

//FTP close connection
ftp_close($ftp_connect);
}
?>
[/code]

Share this post


Link to post
Share on other sites
thank you for the reply.

The problem is that i am using a software which is to be used with Windows 2003 Server and IIS.
How can I change the permissions setting using the above code given

Thanks
Arun

Share this post


Link to post
Share on other sites
as posted

<? fopen("newfile.txt", "w+"); ?>

if you are the owner of the windows meachine then use the folder options ok.

this is not a php issue this is a windows 2003 issue ok.

Share this post


Link to post
Share on other sites
I have set permissions for all the folders which PHP has to write (i.e. were the tool has to upload files)
but its still not working.

If these are stupid questions, pls forgive becoz i am very new to this field

Thanks
Arun

Share this post


Link to post
Share on other sites
i want you to make a folder in the htdocs and call it test then i want you to goto test.php what should have the code here in ok.

when you goto test.php there should be a file made as newfile.txt try.

test.php
[code]
<?
fopen("newfile.txt", "w+");

?>

[/code]

Share this post


Link to post
Share on other sites
Hi friend,

I have tried what u have told.
I have placed the code in test.php and and placed that file in the home directory of my test sit( i am using IIS6.0) then i tried to run from there but there is nothing shown as an output also no  file is created .
I have tried another php code which simply echos some text it is working.
Can you pls identify the problem.
Thanks
Arun

Share this post


Link to post
Share on other sites
I tried with that also i can't see any file created
Is this some problem with php settings


Thanks
Arun

Share this post


Link to post
Share on other sites
sorry yar it is working the problem was that the code shld be added with
<?php....?> instead  of <?...............?>
Now can u help me

Share this post


Link to post
Share on other sites
friend ,
the problrm is that i have to install a project managment tool which works with PHP5.1.6 and MySQL
I installed it properly.Now when i use it to upload documents, the it is not uplading properly, but no error message is shown.
I contacted the program vendors and they told that give the folders permissions for  PHP to write into it.
Hope u now understand my problem.I tried giving permissions for the folders to be writable using the Windows 2003 .is there any other permissions to be set for PHP.
plz help me

Thanks
Arun

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.