upload-functie
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
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
<?
function uploadimage($file,$dir)
{
/*
Give the following messages
1 The filename was already in use
2 Upload was succesful
3 Upload failed
4 No file given
*/
$filename = explode("\\", $file['name']);
$last = count($filename) - 1;
$filename = $filename[$last];
if(file_exists($dir . $filename))
{
$return = 1;
}
elseif(is_uploaded_file($file['tmp_name']))
{
$return = (move_uploaded_file($file['tmp_name'], $dir . $filename)) ? 2 : 3;
}
else
{
$return = 4;
}
return array('status'=>$return,'filename'=>$filename);
}
?>
function uploadimage($file,$dir)
{
/*
Give the following messages
1 The filename was already in use
2 Upload was succesful
3 Upload failed
4 No file given
*/
$filename = explode("\\", $file['name']);
$last = count($filename) - 1;
$filename = $filename[$last];
if(file_exists($dir . $filename))
{
$return = 1;
}
elseif(is_uploaded_file($file['tmp_name']))
{
$return = (move_uploaded_file($file['tmp_name'], $dir . $filename)) ? 2 : 3;
}
else
{
$return = 4;
}
return array('status'=>$return,'filename'=>$filename);
}
?>