php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2006

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 02.07.2006, 17:21  
Neuer Benutzer
 
Registriert seit: 31.05.2006
Beiträge: 16
JoeDoe.asd
JoeDoe.asd eine Nachricht über ICQ schicken
Standard CHMOD Problem: Inappropriate file type or format

Hallo!

Wenn ich in meinem php-script mit chmod() einer anderen datei rechte setzen will kommt immer folgender Fehler:

Warning: chmod(): Inappropriate file type or format .

Der Code sieht folgendermassen aus:

Code:
function chmode($file,$mode)
{
	$pfad = $_SERVER['DOCUMENT_ROOT'];
	if(chmod($pfad."/".$file,$mode))
	{
		$string = "CHMOD gesetzt!";	
	}
	else
	{
		$string = "CHMOD konte nicht gesetzt werden!";
	}
	return $string;
}
$mode ist zum beispiel 0644
und $file ist eine Datei (hallowelt.php).

Was kann man da machen, dass es funktioniert?

Joe
__________________
visit:
www.joedoe.de
www.mythos-clan.de
JoeDoe.asd ist offline  
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 02.07.2006, 18:50  
Erfahrener Benutzer
 
Registriert seit: 08.11.2004
Beiträge: 2.079
Der_Gerhard ist zur Zeit noch ein unbeschriebenes Blatt
Der_Gerhard eine Nachricht über ICQ schicken
Standard

Zitat:
$mode ist zum beispiel 0644
und $file ist eine Datei (hallowelt.php).
Bei Deinen Angaben weiß man nicht so genau, was richtig ist, weil beim $file fehlen ja offensichtlich Anführungszeichen. Hat Du sie nur dort weggelassen oder auch beim $mode?
__________________
**********************************
Nein, ich bin nicht die Signatur.
Ich putze hier nur.
**********************************
Der_Gerhard ist offline  
Alt 03.07.2006, 01:05  
axo
Erfahrener Benutzer
 
Registriert seit: 24.12.2004
Beiträge: 1.814
axo ist zur Zeit noch ein unbeschriebenes Blatt
Standard

sftw nach der fehlermeldung. das erste suchergebnis.
und nochmal genau auf http://www.php.net/chmod lesen, wie $mode sein muss.

PHP-Code:
$eins 0644;
$zwei '0644';
var_dump($eins);
var_dump($zwei);
var_dump($eins === $zwei); 
grüße
axo
axo ist offline  
Alt 03.07.2006, 01:32  
Gast
 
Beiträge: n/a
Standard Re: CHMOD Problem: Inappropriate file type or format

Zitat:
Zitat von JoeDoe.asd
Wenn ich in meinem php-script mit chmod() einer anderen datei rechte setzen will kommt immer folgender Fehler:

Warning: chmod(): Inappropriate file type or format .

Code:
	if(chmod($pfad."/".$file,$mode))
$mode ist zum beispiel 0644
Das geht so nicht. chmod() erwartet eine Oktalzahl, die Du als Literal angeben mußt, weil sonst das automatische Typecasting zuschlägt und die Oktalzahl 0644 in die Dezimalzahl 420 umwandelt. Mit 420 kann allerdings chmod nix anfangen. Klingt komisch, ist aber so.

Korrekt:
chmod($datei, 0644);

Falsch:
$mode = 0644;
chmod($datei, $mode);
 
Alt 03.07.2006, 01:37  
axo
Erfahrener Benutzer
 
Registriert seit: 24.12.2004
Beiträge: 1.814
axo ist zur Zeit noch ein unbeschriebenes Blatt
Standard Re: CHMOD Problem: Inappropriate file type or format

Zitat:
Zitat von ignatz
Falsch:
$mode = 0644;
chmod($datei, $mode);
quatsch. probier's aus.
axo ist offline  
Alt 03.07.2006, 01:48  
Gast
 
Beiträge: n/a
Standard Re: CHMOD Problem: Inappropriate file type or format

Zitat:
Zitat von axo
Zitat:
Zitat von ignatz
Falsch:
$mode = 0644;
chmod($datei, $mode);
quatsch. probier's aus.
Hab ich doch:
http://test.php-help.info/test/27/

Allerdings findet man da
http://de3.php.net/chmod
in den Userkommentaren einen Hinweis:
Zitat:
memp
23-Aug-2005 12:04
If you are storing your mode in a variable like

$mode = 0755;

you will run into the inevitable octal mode problem. An easy way around that is to use the octdec() function.

chmod("some_filename.ext", octdec($mode));
 
Alt 03.07.2006, 02:05  
axo
Erfahrener Benutzer
 
Registriert seit: 24.12.2004
Beiträge: 1.814
axo ist zur Zeit noch ein unbeschriebenes Blatt
Standard

wtf? ist doch egal, ob du chmod() dezimal 420 oder oktal 644 übergibst. die rechte bleiben rw-r-r .
axo ist offline  
Alt 03.07.2006, 10:46  
Neuer Benutzer
 
Registriert seit: 31.05.2006
Beiträge: 16
JoeDoe.asd
JoeDoe.asd eine Nachricht über ICQ schicken
Standard

hallo!

die funktion sieht jetzt so aus:

PHP-Code:
function chmode($file,$mode)
{
    if(
chmod(stand."/".$file,octdec($mode)))
    {
        
$string "CHMOD gesetzt!";    
    }
    else
    {
        
$string "CHMOD konte [b]nicht[/b] gesetzt werden!";
    }
    return 
$string;

und funktioniert auch fehlerfrei!!!!

Danke für die Hilfe!

Joe
__________________
visit:
www.joedoe.de
www.mythos-clan.de
JoeDoe.asd ist offline  
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Erledigt] Unix file lesen? PHP-Fortgeschrittene 15 08.06.2005 18:05
Problem: Variablenübergabe bei file() Lia PHP Tipps 2005 9 12.05.2005 10:46
[Erledigt] File download > kleines Problem PHP Tipps 2005 3 11.05.2005 23:11
update auf php 5.0.4 robo47 Server, Hosting und Workstations 6 10.04.2005 19:00
fieses mieses problem beim öffnen einer file PHP Tipps 2005 10 02.02.2005 19:40
CHMOD Problem web2 PHP Tipps 2005 2 06.01.2005 15:43
[Erledigt] PHP Script Problem PHP Tipps 2005 12 06.01.2005 12:38
[Erledigt] [gelöst] Anfänger: Datums Format Problem... Datenbanken 10 29.11.2004 21:41
Problem mit File Upload PHP Tipps 2004-2 2 19.11.2004 13:41
Logik Problem, delete File... PHP-Fortgeschrittene 6 07.11.2004 18:27
problem bei file 2x über ein formular weiterzureichen. Promaetheus PHP Tipps 2004-2 2 07.11.2004 00:49
[Erledigt] problem mit ftp funktionen und chmod PHP-Fortgeschrittene 7 19.08.2004 16:59
file(); problem PHP Tipps 2004 3 12.07.2004 11:51
Problem mit css File HTML, Usability und Barrierefreiheit 3 28.06.2004 01:17
[Erledigt] File Upload: PRoblem mit Upload directory PHP Tipps 2004 3 26.06.2004 13:20

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
chmod inappropriate file type or format, inappropriate file type or format, chmod() [function.chmod]: inappropriate file type or format, pssniffer error: inappropriate file type or format, inappropriate type, php chmod inappropriate file type or format in, \inappropriate file type or format\, chmod() [function.chmod]: inappropriate file type or format in, warning: chmod() [function.chmod]: inappropriate file type or format, php inappropriate file type or format, php chmod \inappropriate file type or format in\, inappropriate file type or format php, chmod: inappropriate file type or format, chmod dezimal, chmod(): inappropriate file type or format, chmod \inappropriate file type or format\, [function.chmod]: inappropriate file type or format, chmod inappropriate file type or format in, warning: chmod(): inappropriate file type or format, file type php

Alle Zeitangaben in WEZ +2. Es ist jetzt 18:07 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.