open_basedir restriction in effect
ik heb de volgende 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
* DevHouse Upload Script Version 1
* Created by Tom Keim
*/
error_reporting(E_ALL);
ini_set('display_errors','On');
$i=2;
function fewn($file, $type, $i)
{
$oi = ($i<=9) ? '0'.$i : $i;
$nfile = $file.$oi.'.'.$type;
if(file_exists($nfile))
{
fewn($file, $type, $oi);
}
else
{
return $nfile;
}
}
$ip = $_SERVER['REMOTE_ADDR'];
$upload_dir = md5($ip);
$upload_dir = preg_replace('#[0-6]#', '', $upload_dir);
$upload_dir = preg_replace('#[a-bA-b]#', '', $upload_dir);
//
$types = array();
$types['L'] = array ( "image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng" );
$types['S'] = array ( "jpg", "jpeg", "gif", "png");
//
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset($_POST['uploadFile']))
{
if(in_array($_FILES['file']['type'], $types['L']))
{
$file = explode( "." , $_FILES['file']['name'] );
$type = array_pop($file);
$name = $file[0];
if(in_array($type, $types['S']))
{
$dir = 'ul/'.$upload_dir.'/';
if(!is_dir($dir))
{
mkdir($dir, 0777);
}
$fullfile = $dir . $name;
if(file_exists($fullfile.'.'.$type))
{
$filename = fewn($fullfile, $type, $i);
if(move_uploaded_file($_FILES['file']['tmp_name'], $filename))
{
echo 'bestand geupload!';
}
else
{
echo 'bestand niet geupload!';
}
}
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'], $fullfile.'.'.$type))
{
echo 'bestand geupload!';
}else{echo 'bestand niet geupload!';} }
}
else
{
echo 'De bestand extentie is niet toegestaan, je kunt alleen gebruikmaken van jpg, jpeg, gif en png';
}
}
else
{
echo 'Het type bestand is niet toegestaan, de volgende bestand types worden toegestaan: jpg, jpeg, gif en png';
}
}
}
?>
<form method="post" enctype="multipart/form-data" action="index.php">
<input type="file" name="file" /><br />
<input type="submit" value="Bestand Uploaden" name="uploadFile" />
</form>
/*
* DevHouse Upload Script Version 1
* Created by Tom Keim
*/
error_reporting(E_ALL);
ini_set('display_errors','On');
$i=2;
function fewn($file, $type, $i)
{
$oi = ($i<=9) ? '0'.$i : $i;
$nfile = $file.$oi.'.'.$type;
if(file_exists($nfile))
{
fewn($file, $type, $oi);
}
else
{
return $nfile;
}
}
$ip = $_SERVER['REMOTE_ADDR'];
$upload_dir = md5($ip);
$upload_dir = preg_replace('#[0-6]#', '', $upload_dir);
$upload_dir = preg_replace('#[a-bA-b]#', '', $upload_dir);
//
$types = array();
$types['L'] = array ( "image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng" );
$types['S'] = array ( "jpg", "jpeg", "gif", "png");
//
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(isset($_POST['uploadFile']))
{
if(in_array($_FILES['file']['type'], $types['L']))
{
$file = explode( "." , $_FILES['file']['name'] );
$type = array_pop($file);
$name = $file[0];
if(in_array($type, $types['S']))
{
$dir = 'ul/'.$upload_dir.'/';
if(!is_dir($dir))
{
mkdir($dir, 0777);
}
$fullfile = $dir . $name;
if(file_exists($fullfile.'.'.$type))
{
$filename = fewn($fullfile, $type, $i);
if(move_uploaded_file($_FILES['file']['tmp_name'], $filename))
{
echo 'bestand geupload!';
}
else
{
echo 'bestand niet geupload!';
}
}
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'], $fullfile.'.'.$type))
{
echo 'bestand geupload!';
}else{echo 'bestand niet geupload!';} }
}
else
{
echo 'De bestand extentie is niet toegestaan, je kunt alleen gebruikmaken van jpg, jpeg, gif en png';
}
}
else
{
echo 'Het type bestand is niet toegestaan, de volgende bestand types worden toegestaan: jpg, jpeg, gif en png';
}
}
}
?>
<form method="post" enctype="multipart/form-data" action="index.php">
<input type="file" name="file" /><br />
<input type="submit" value="Bestand Uploaden" name="uploadFile" />
</form>
het is een upload script. als ik dit uitvoer, en het bestand wat ik wil uploaden bestaat al, wordt er automatisch door de functie fewn 02 achter geplaatst, de bedoeling is dat als het bestand met 02 erachter ook bestaat dat er dan 03 wordt achter geplaatst, dit zie je in de functie fewn. Maar als 02 bestaat, dan krijg ik helaas een error:
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/deb16749/:/tmp:/usr/local/lib/php/) in /usr/home/deb16749/domains/devhouse.nl/public_html/upload/index.php on line 52
weet iemand hoe ik dit op kan lossen???
Tom
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
function fewn($file, $type, $i)
{
$oi = ($i<=9) ? '0'.$i : $i;
$nfile = $file.$oi.'.'.$type;
if(file_exists($nfile))
{
fewn($file, $type, $i + 1);
}
else
{
return $nfile;
}
}
?>
function fewn($file, $type, $i)
{
$oi = ($i<=9) ? '0'.$i : $i;
$nfile = $file.$oi.'.'.$type;
if(file_exists($nfile))
{
fewn($file, $type, $i + 1);
}
else
{
return $nfile;
}
}
?>