473,473 Members | 4,257 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CHMOD back and forth in same script?

77 New Member
Hiya.

I have a file download script which chmods the file permissions to read/downloadable when used.

However I have tried to make it so that the same script will chmod the file permissions back to not readable again after the download is initiated, but it does not work.

The chmod works, it's just that I cant make the last chmod to wait until the download has initiated.
Sleep doesnt help because it seems as if that delays the whole script rather than the codes below the string.

Expand|Select|Wrap|Line Numbers
  1. chmod("$fDirr", 0777);
  2.  
  3. echo "<meta http-equiv='Refresh' content='1;url=files/$filename'> ";
  4.  
  5. chmod("$fDirr", 0600);
  6.  
So how can I solve this? :)
Jun 21 '10 #1
1 1307
Markus
6,050 Recognized Expert Expert
Well, the issue is that the PHP is interpreted prior to the HTML. Ergo, the last chmod() is run before that output reaches the browser.

My suggestion, instead, is to *not* give a user access to the files (and not mess around with the file permissions). but to instead send the file for download with PHP. Therefore, only the Apache/PHP user needs read permissions on the file.

See Part 4 to Atli's article here.

Mark.
Jun 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rigo | last post by:
I have an .asp scrip to retrieve information from a Sybase database, running it on NT server (IIS4) work fine. When I am runing the same script on server 2003 (IIS6) work fine when the rows to...
0
by: enahar | last post by:
I want to validate a cell wheather a value is greater than 0 or not.If value is greater than 0 then I want to show messagebox and focus back the same cell else move to the other cell. I am...
2
by: Saverio Tedeschi | last post by:
Hi all gurus, I've found no article about my question. Is it possible from ASP.NET to call a page without the buttons to move back and forward?
13
by: tshad | last post by:
I have some nested DataGrids in my Datalist. There could be 20 datalist items. If I scroll down to the 18th item and expand it to show the DataGrid, the page always goes back to the beginning...
4
by: Rob | last post by:
I am working with an ERP package that has the capability to pass variables to and from VB script.... Is there a way from within VB script to call a vb.net program AND pass it variables from the...
3
by: Bob Sanderson | last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet. The idea is to display a list of records, with the last line of the list being an input form. When the user enters data...
0
by: java | last post by:
Hi there! After I overcame some short_open_tag (thanks, Rik!) I encounter another strange php-behaviour. The script I just got to work on the windows-commandline obviously does as php.ini tells...
3
by: pnsreee | last post by:
Hi All, I am trying to print a log file created in the same script with the code bellow. but Im not getting output on screen. The output file is created using rediretion of output. ...
5
by: simon m | last post by:
Hi All, I have a script sitting on my web server called auto_mail.php5. I would like this to be used two different ways. One way would be for a web form to call it as submit action on a form. I...
5
by: Christopher Brewster | last post by:
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.