Voor mijn site, (justmental): doe maar niet, is het de bedoeling dat geregistreerde leden drivers kunnen uploaden. Nu gaat dit goed tot ong. 5 MB, maar daarboven (ik heb het geprobeerd met een 15 MB file) gaat het fout.
Nu gebruik ik er een class voor, vanaf phpclasses.org, dat is deze:
Maar volgens mij ligt de fout niet aan de class..
Iemand enig idee ?
Nu gebruik ik er een class voor, vanaf phpclasses.org, dat is deze:
code:
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
88
89
90
91
92
93
94
95
96
97
98
| Class Upload
{
var $maxupload_size = 500000;
var $_FILES;
var $errors;
function Upload($_FILES)
{
$this->HTTP_POST_FILES = $_FILES;
$this->isPosted = false;
}
function save($directory, $field, $overwrite,$mode=0777)
{
$this->isPosted = true;
if ($this->HTTP_POST_FILES[$field]['size'] < $this->maxupload_size && $this->HTTP_POST_FILES[$field]['size'] >0)
{
$noerrors = true;
$this->isPosted = true;
// Get names
$tempName = $this->HTTP_POST_FILES[$field]['tmp_name'];
$file = $this->HTTP_POST_FILES[$field]['name'];
$all = $directory.$file;
// Copy to directory
if (file_exists($all))
{
if ($overwrite)
{
@unlink($all) || $noerrors=false; $this->errors = "Upload class save error: unable to overwrite ".$all."<BR>";
@copy($tempName,$all) || $noerrors=false; $this->errors .= "Upload class save error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $ernoerrorsrors=false; $this->errors .= "Upload class save error: unable to change permissions for: ".$all."<BR>";
}
} else{
@copy($tempName,$all) || $noerrors=false;$this->errors = "Upload class save error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $noerrors=false;$this->errors .= "Upload class save error: unable to change permissions for: ".$all."<BR>";
}
return $noerrors;
} elseif ($this->HTTP_POST_FILES[$field]['size'] > $this->maxupload_size) {
$this->errors = "File size exceeds maximum file size of ".$this->maxuploadsize." bytes";
return false;
} elseif ($this->HTTP_POST_FILES[$field]['size'] == 0) {
$this->errors = "File size is 0 bytes";
return false;
}
}
function saveAs($filename, $directory, $field, $overwrite,$mode=0777)
{
$this->isPosted = true;
if ($this->HTTP_POST_FILES[$field]['size'] < $this->maxupload_size && $this->HTTP_POST_FILES[$field]['size'] >0)
{
$noerrors = true;
// Get names
$tempName = $this->HTTP_POST_FILES[$field]['tmp_name'];
$all = $directory.$filename;
// Copy to directory
if (file_exists($all))
{
if ($overwrite)
{
@unlink($all) || $noerrors=false; $this->errors = "Upload class saveas error: unable to overwrite ".$all."<BR>";
@copy($tempName,$all) || $noerrors=false; $this->errors .= "Upload class saveas error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $noerrors=false; $this->errors .= "Upload class saveas error: unable to copy to".$all."<BR>";
}
} else{
@copy($tempName,$all) || $noerrors=false; $this->errors = "Upload class saveas error: unable to copy to ".$all."<BR>";
@chmod($all,$mode) || $noerrors=false; $this->errors .= "Upload class saveas error: unable to change permissions for: ".$all."<BR>";
}
return $noerrors;
} elseif ($this->HTTP_POST_FILES[$field]['size'] > $this->maxupload_size) {
$this->errors = "File size exceeds maximum file size of ".$this->maxuploadsize." bytes";
return false;
} elseif ($this->HTTP_POST_FILES[$field]['size'] == 0) {
$this->errors = "File size is 0 bytes";
return false;
}
}
function getFilename($field)
{
return $this->HTTP_POST_FILES[$field]['name'];
}
function getFileMimeType($field)
{
return $this->HTTP_POST_FILES[$field]['type'];
}
function getFileSize($field)
{
return $this->HTTP_POST_FILES[$field]['size'];
}
} |
Maar volgens mij ligt de fout niet aan de class..
Iemand enig idee ?
[ Voor 12% gewijzigd door justmental op 05-08-2003 15:45 ]