Uploaden permission
K'heb een klein probleempje met uploaden. Ik krijg een error met permission denied, maar ik hem et alles CHMOD 777 staan.
errors:
Warning: mkdir() [function.mkdir]: Permission denied in domein.nl/pages/uploaden/php.php on line 31
Warning: mkdir() [function.mkdir]: No such file or directory in domein.nl/pages/uploaden/php.php on line 35
Warning: move_uploaded_file(/useruploads/2/1WAT.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in domein.nl/pages/uploaden/php.php on line 40
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpjulp1X' to '/useruploads/2/1WAT.png' in domein.nl/pages/uploaden/php.php on line 40
Code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
if($_POST['upl']){
$err = 0;
$checkmime = mysql_query("SELECT type FROM mime WHERE mime = '".$_FILES['f']['type']."'");
if(mysql_num_rows($checkmime) < 1){
$err = 1;
$errormime = 'Mimetype "'.$_FILES['f']['type'].'" word niet geaccepteerd.<br>';
}
$newtotal = ($_FILES['f']['size'] / 1024 / 1024) + getmb(login("id"));
if($newtotal > login("up_limit")){
$err = 1;
$errorsize = 'Dit bestand is te groot.<br>';
}
if($err == 0){
$err2 = 0;
$lastimg = mysql_fetch_assoc(mysql_query("SELECT id FROM uploads ORDER BY id DESC LIMIT 1"));
$newimg = $lastimg['id'] + 1;
//Dircheck
if(!is_dir("/useruploads/")){
mkdir("/useruploads/");
}
if(!is_dir("useruploads/".login("id")."/")){
mkdir("/useruploads/".login("id")."/");
}
$getmime = mysql_fetch_assoc($checkmime);
$type = $getmime['type'];
if(move_uploaded_file($_FILES['f']['tmp_name'], "/useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name']))){
mysql_query("INSERT INTO uploads (userid,type,filename,size) VALUES ('".login("id")."', '".$type."', '/".login("id")."/".$newimg.basename($_FILES['f']['name'])."', '".$_FILES['f']['size']."')");
}else{
$err2 = 1;
}
}else{
$err2 = 2;
}
$err = 0;
$checkmime = mysql_query("SELECT type FROM mime WHERE mime = '".$_FILES['f']['type']."'");
if(mysql_num_rows($checkmime) < 1){
$err = 1;
$errormime = 'Mimetype "'.$_FILES['f']['type'].'" word niet geaccepteerd.<br>';
}
$newtotal = ($_FILES['f']['size'] / 1024 / 1024) + getmb(login("id"));
if($newtotal > login("up_limit")){
$err = 1;
$errorsize = 'Dit bestand is te groot.<br>';
}
if($err == 0){
$err2 = 0;
$lastimg = mysql_fetch_assoc(mysql_query("SELECT id FROM uploads ORDER BY id DESC LIMIT 1"));
$newimg = $lastimg['id'] + 1;
//Dircheck
if(!is_dir("/useruploads/")){
mkdir("/useruploads/");
}
if(!is_dir("useruploads/".login("id")."/")){
mkdir("/useruploads/".login("id")."/");
}
$getmime = mysql_fetch_assoc($checkmime);
$type = $getmime['type'];
if(move_uploaded_file($_FILES['f']['tmp_name'], "/useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name']))){
mysql_query("INSERT INTO uploads (userid,type,filename,size) VALUES ('".login("id")."', '".$type."', '/".login("id")."/".$newimg.basename($_FILES['f']['name'])."', '".$_FILES['f']['size']."')");
}else{
$err2 = 1;
}
}else{
$err2 = 2;
}
Waarna, als ik een bestand upload met toegestaan mimetype, ik deze output van $err krijg:
$err = 0
$err2 = 1
Kan iemand mij helpen?
Gewijzigd op 29/05/2011 22:29:20 door Maestro Roboroads
if(!is_dir("/useruploads/")){
mkdir("/useruploads/");
Gewijzigd op 29/05/2011 22:56:50 door - SanThe -
Warning: mkdir() [function.mkdir]: No such file or directory in domein.nl/pages/uploaden/php.php on line 35
Warning: move_uploaded_file(/useruploads/2/1WAT.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in domein.nl/pages/uploaden/php.php on line 40
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpef7vH9' to '/useruploads/2/1WAT.png' in domein.nl/pages/uploaden/php.php on line 40
nieuwe code (nu ook ff tussen phptags, voor de kleurtjes :P):
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
if(!login("loggedin")){
header("Location: home");
}
if($_POST['upl']){
$err = 0;
$checkmime = mysql_query("SELECT type FROM mime WHERE mime = '".$_FILES['f']['type']."'");
if(mysql_num_rows($checkmime) < 1){
$err = 1;
$errormime = 'Mimetype "'.$_FILES['f']['type'].'" word niet geaccepteerd.<br>';
}
$newtotal = ($_FILES['f']['size'] / 1024 / 1024) + getmb(login("id"));
if($newtotal > login("up_limit")){
$err = 1;
$errorsize = 'Dit bestand is te groot.<br>';
}
if($err == 0){
$err2 = 0;
$lastimg = mysql_fetch_assoc(mysql_query("SELECT id FROM uploads ORDER BY id DESC LIMIT 1"));
$newimg = $lastimg['id'] + 1;
//Dircheck
if(!is_dir("useruploads/")){
mkdir("useruploads/");
}
if(!is_dir("useruploads/".login("id")."/")){
mkdir("/useruploads/".login("id")."/");
}
$getmime = mysql_fetch_assoc($checkmime);
$type = $getmime['type'];
if(move_uploaded_file($_FILES['f']['tmp_name'], "/useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name']))){
mysql_query("INSERT INTO uploads (userid,type,filename,size) VALUES ('".login("id")."', '".$type."', '/".login("id")."/".$newimg.basename($_FILES['f']['name'])."', '".$_FILES['f']['size']."')");
}else{
$err2 = 1;
}
}else{
$err2 = 2;
}
if($err2 == 0){
$confirm = "<font color=\"green\">Bestand geupload!</font>";
}elseif($err2 == 1){
$confirm = "<font color=\"red\">Bestand is geaccepteerd, maar er ging iets fout bij het uploaden. Probeer het opnieuw.<br>useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name'])."</font>";
}
}
?>
if(!login("loggedin")){
header("Location: home");
}
if($_POST['upl']){
$err = 0;
$checkmime = mysql_query("SELECT type FROM mime WHERE mime = '".$_FILES['f']['type']."'");
if(mysql_num_rows($checkmime) < 1){
$err = 1;
$errormime = 'Mimetype "'.$_FILES['f']['type'].'" word niet geaccepteerd.<br>';
}
$newtotal = ($_FILES['f']['size'] / 1024 / 1024) + getmb(login("id"));
if($newtotal > login("up_limit")){
$err = 1;
$errorsize = 'Dit bestand is te groot.<br>';
}
if($err == 0){
$err2 = 0;
$lastimg = mysql_fetch_assoc(mysql_query("SELECT id FROM uploads ORDER BY id DESC LIMIT 1"));
$newimg = $lastimg['id'] + 1;
//Dircheck
if(!is_dir("useruploads/")){
mkdir("useruploads/");
}
if(!is_dir("useruploads/".login("id")."/")){
mkdir("/useruploads/".login("id")."/");
}
$getmime = mysql_fetch_assoc($checkmime);
$type = $getmime['type'];
if(move_uploaded_file($_FILES['f']['tmp_name'], "/useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name']))){
mysql_query("INSERT INTO uploads (userid,type,filename,size) VALUES ('".login("id")."', '".$type."', '/".login("id")."/".$newimg.basename($_FILES['f']['name'])."', '".$_FILES['f']['size']."')");
}else{
$err2 = 1;
}
}else{
$err2 = 2;
}
if($err2 == 0){
$confirm = "<font color=\"green\">Bestand geupload!</font>";
}elseif($err2 == 1){
$confirm = "<font color=\"red\">Bestand is geaccepteerd, maar er ging iets fout bij het uploaden. Probeer het opnieuw.<br>useruploads/".login("id")."/".$newimg.basename($_FILES['f']['name'])."</font>";
}
}
?>
Dit is Btw nu de hele code
Gewijzigd op 29/05/2011 22:41:34 door Maestro Roboroads
mkdir("/useruploads/".login("id")."/");
Gewijzigd op 29/05/2011 22:55:57 door Maestro Roboroads