473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

php chmod?

say i have a php script that i access via the web and that creates a
file whose permissions are changed to 600 (ie. only the owner can read
or write the file). when i try to download the file with the
webbrowser... i can. what i want is to not be able to download the
file, itself. i only want the php script i wrote to download the
file... how could i do this? is it simply a matter of changing the
permissions?

anyways, here's my code:

<?
system("ls -l > test.txt");
chmod("test.txt", 0600);
?>
Jul 17 '05 #1
2 4619
KAH
yawnmoth <te*******@yahoo.com> wrote in
news:2s********************************@4ax.com:
say i have a php script that i access via the web and that creates a
file whose permissions are changed to 600 (ie. only the owner can read
or write the file). when i try to download the file with the
webbrowser... i can. what i want is to not be able to download the
file, itself. i only want the php script i wrote to download the
file... how could i do this? is it simply a matter of changing the
permissions?


To answer to this is simple: PHP is being run by the same user as the
webserver.

KAH
Jul 17 '05 #2
Hi,
yawnmoth wrote:
say i have a php script that i access via the web and that creates a
file whose permissions are changed to 600 (ie. only the owner can read
or write the file). when i try to download the file with the
webbrowser... i can. what i want is to not be able to download the
file, itself. i only want the php script i wrote to download the
file... how could i do this? is it simply a matter of changing the
permissions? Nop, here we need to do some tricky stuff.
You can place the file on a other location like /home/foo (the
permissions must be so that php can read an write here.
You webserver looks in the /var/www/htdocs (or something like thist) or
maybe in /home/foo/public_html. So you can have php read an write the
file, but you can not make an URL that point to that file.
anyways, here's my code:

<?
system("ls -l > test.txt");
chmod("test.txt", 0600);
?>

So long Alexander

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Daniel | last post by:
Hi, From what I read from the PHP manual, chmod on a Windows platform should have no effect, and that seems totally normal (unless someone on sourceforge has a windows port of that!). I...
6
by: Ask Josephsen | last post by:
Hi NG If I write the following: <?php $file="myfile.JPG"; if ( getmyuid()==fileowner ( $file ) ) { chgrp ( $file, getmygid() ); chown ( $file, getmyuid() );
1
by: Xuan Yuan | last post by:
I'm using Windows XP Professional and have no FTP installed. Instead, I use Command Promt. I need to CHMOD a PHP file, so I type "CHMOD 775 file-path",but get "'CHMOD'is not recognized as an internal...
4
by: Ian N | last post by:
Hi i'm having a problem with file permissions of upload, they appear to be being set to only readable by the administrator, so anyone browsing the site gets a 403 forbidden error when they try and...
5
by: Stewart | last post by:
Hi, I'm working on a program in VC++ right now that needs to set file permissions of a given file to 766 (read/write/execute). Now I've found the _chmod() function in the API help docs, but that...
2
by: Freebird | last post by:
Hello everyone, =] I need your help, I'm creating a script that will work in many servers, and there's this part, where you can update a list, so the script goes from the client's machine to...
1
by: James Colannino | last post by:
Ok, so now I have a very interesting problem, this time related to os.chmod. I have the following in a text file: 0600. My script reads that number as a string and converts it to an integer for...
3
by: webhead | last post by:
I have a web where users can upload photos, but they want to also be able to delete them. The directory can have chmod changes but it won't let me chmod the files and unlink them. I'm assuming it...
3
by: Rik | last post by:
Hello, first of all, my provider sucks, newsserver is down for the #nth time now, offcourse when I have an urgent question.... So this will be me first time using Google Groups, forgive me if...
1
by: lawrence k | last post by:
I've a simple script to transfer some files from one domain to another, with both domains living on the same server. The files in both directories are already chmod 777. Yet after transfer, I try...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.