how to chmod-777 a DIRECTORY (not a file) via PHP?
Moderator: General Moderators
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
how to chmod-777 a DIRECTORY (not a file) via PHP?
Hi @all,
I am working on an upload-script (use for the webmaster only). It works well if I put the directory for the files to upload on chmod-777 (by telnet or ftp). The script is used to upload new files other user can download and at the same time updating the database with the file infos, descriptions, associated links and further stuff.
I want this directory to be a 'normal' chmod-755 (because it´s accessible for any user), and only for the process of uploading it should be set on 777.
The chmod('filename', 0755)-function in PHP does only work with existing files, not for directories.
Can anyone help?
thanx,
Mazzo
I am working on an upload-script (use for the webmaster only). It works well if I put the directory for the files to upload on chmod-777 (by telnet or ftp). The script is used to upload new files other user can download and at the same time updating the database with the file infos, descriptions, associated links and further stuff.
I want this directory to be a 'normal' chmod-755 (because it´s accessible for any user), and only for the process of uploading it should be set on 777.
The chmod('filename', 0755)-function in PHP does only work with existing files, not for directories.
Can anyone help?
thanx,
Mazzo
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
thanx a lot! That was exactly what I was looking for. (I used passthru() in the end)
But now I get strange double-slashes in the $name of the file I selected for upload. That makes it impossible to find the file.
If I change them with stripslashes I guess that I changed the type of the variable to a string.
Here´s my form:
<form action=\"uploader.php\" method=\"post\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"262144000\"<br>
<input type=\"file\" name=\"fupload\" size=\"40\"><br>
...(following several database commands - this works, I tested it)...
<input type=\"submit\" value=\"upload\">
</form>
When I submit I get this message:
Unable to open 'C:\\temp\\temp02.pdf' for reading:...
Where do the double-slashes come from? I didn´t had this before. The small and very primitive script (only uploading without passthru() to a 777-directory) works, but I copied exactly this code to the script which adds a bit of mysql after the upload has been done.
*confused*,
mazzo[/i]
But now I get strange double-slashes in the $name of the file I selected for upload. That makes it impossible to find the file.
If I change them with stripslashes I guess that I changed the type of the variable to a string.
Here´s my form:
<form action=\"uploader.php\" method=\"post\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"262144000\"<br>
<input type=\"file\" name=\"fupload\" size=\"40\"><br>
...(following several database commands - this works, I tested it)...
<input type=\"submit\" value=\"upload\">
</form>
When I submit I get this message:
Unable to open 'C:\\temp\\temp02.pdf' for reading:...
Where do the double-slashes come from? I didn´t had this before. The small and very primitive script (only uploading without passthru() to a 777-directory) works, but I copied exactly this code to the script which adds a bit of mysql after the upload has been done.
*confused*,
mazzo[/i]
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
I have still trouble with the chmods...
I have tried the following
system("chmod 0777 test", $a1);
exec("chmod 0777 test", $a2[], $a21);
passthru("chmod 0777 test", $a3);
The script executed is in the directory in which 'test' is.
In all cases I get '1' as return value. That means that nothing has changed. The directory 'test' has still the same chmods (755 instead of 777).
What is my mistake?
I have tried the following
system("chmod 0777 test", $a1);
exec("chmod 0777 test", $a2[], $a21);
passthru("chmod 0777 test", $a3);
The script executed is in the directory in which 'test' is.
In all cases I get '1' as return value. That means that nothing has changed. The directory 'test' has still the same chmods (755 instead of 777).
What is my mistake?
-
mazzogeddon
- Forum Newbie
- Posts: 7
- Joined: Thu Aug 01, 2002 7:23 am
- Location: Berlin
I think it is a problem which is caused by my providers webserver configuration. something as
system("ls -l", $result)
works fine. But the chmod does not have any affect...
So I have finally given the chmods by ftp and the script works. I need stripslashes() to get rid of those doubleslashes in the filename.
And the Norton-Internet-Scurity did also disturb the process... better turn it off during those uploads.
system("ls -l", $result)
works fine. But the chmod does not have any affect...
So I have finally given the chmods by ftp and the script works. I need stripslashes() to get rid of those doubleslashes in the filename.
And the Norton-Internet-Scurity did also disturb the process... better turn it off during those uploads.