Jump to content


Photo

Giving permissions for PHP to write in folders


  • Please log in to reply
16 replies to this topic

#1 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 30 August 2006 - 07:06 AM

Hi Friends,

I am using PHP5.1.6 with MYSQL5.0 and IIS6.0 (Windows 2003 Server)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 :(


#2 ScottRiley

ScottRiley
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 30 August 2006 - 09:25 AM

If you'#re creating a file using fopen, you need to include "w+" e.g. to create the file "newfile.txt" use
<? fopen("newfile.txt", "w+"); ?>


#3 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 31 August 2006 - 03:19 AM

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

#4 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 03:35 AM

Hi friend,

If someone knows about this problem pls help me. ???

#5 JayBachatero

JayBachatero
  • Members
  • PipPipPip
  • Advanced Member
  • 296 posts
  • LocationQueens NY

Posted 01 September 2006 - 03:43 AM

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
<?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);
	}
?>

JayBachatero
SMF Developer && Converter Specialist

#6 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 04:09 AM

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

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:13 AM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 04:18 AM

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

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:19 AM


try this way then

<? fopen("newfile.txt", "a+"); ?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 04:26 AM

Can u please tell were this code have to be writen.

thanks
Arun


#11 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:29 AM

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
<?
fopen("newfile.txt", "w+");

?>




Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#12 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 04:48 AM

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

#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:52 AM

try agin with the letter a+
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 05:10 AM

I tried with that also i can't see any file created
Is this some problem with php settings


Thanks
Arun

#15 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 05:17 AM

sorry yar it is working the problem was that the code shld be added with
<?php....?> instead  of <?...............?>
Now can u help me

#16 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 05:35 AM

you got it to work now so what is it you need help with mate.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#17 arunvg

arunvg
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 01 September 2006 - 06:06 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users