PHP file info gaat verkeerd
Ik heb een upload systeempje dat werkt via uploadify, er is echter een probleem: uploadify stuurt geen MIME types mee (komt door flash, die stuurt alleen: application/octet-stream mee).
Op het uploadify forum zag ik dat je dit zo kon oplossen:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$_FILES['Filedata']['type'] = finfo_file($finfo, $_FILES['Filedata']['tmp_name']);
finfo_close($finfo);
?>
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$_FILES['Filedata']['type'] = finfo_file($finfo, $_FILES['Filedata']['tmp_name']);
finfo_close($finfo);
?>
Echter werkt het uploaden soms niet, door te debuggen ben ik erachter gekomen dat het aan het bovenstaande stukje ligt.
Ik krijg verder ook geen errors in mijn error log of in de response.
Weet iemand wat het is, of hoe ik eventueel op een andere manier het MIME-type kan ophalen?
Alvast bedankt,
Milan
PHP Warning: system() has been disabled for security reasons in ..
Gewijzigd op 09/06/2013 11:18:53 door Milan Drossaerts
Of je gaat naar een hoster die het wel toestaat.
Of je probeert een custom php.ini te gebruiken.
Kijk eens in je phpinfo of je suphp gebruikt.
Want dan zou je dat eventueel kunnen proberen.
Met welkte mime types gaat het verkeerd?
Hmm op dit moment werkt geen enkel bestand meer.. Na 30 seconden geeft uploadify het op, ik denk dat het iets is met max execution time, maar je hebt toch geen 30 seconden nodig voor een bestand uploaden?
Gewijzigd op 09/06/2013 11:38:31 door Milan Drossaerts
Quote:
bestand hangt 'ie vast oid bij dat stukje code
Hoe groot is dat bestand?
Heb je niet gewoon de max execution time overschreden of is het bestand niet te groot?
Hier mijn code; wel een beetje slordig wegens debugging:
De eerste 2 mails ontvang ik, die erna niet meer
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
require_once('/home/milan/domains/milandrossaerts.nl/public_html/projecten/e-motion/includes/config.php');
$_SERVER['DOCUMENT_ROOT'] = '/home/milan/domains/milandrossaerts.nl/fileUpload/';
//$_SERVER['DOCUMENT_ROOT'] = str_replace('public_html', '', $_SERVER['DOCUMENT_ROOT']) . 'fileUpload/';
mail('[email protected]', 'test', 'test');
if (!empty($_FILES))
{
mail ('[email protected]', 'joa', $_FILES['Filedata']['tmp_name']);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$_FILES['Filedata']['type'] = finfo_file($finfo, $_FILES['Filedata']['tmp_name']);
finfo_close($finfo);
mail('[email protected]', 'jeps', 'jeps');
if ($core->fileCheck($_FILES['Filedata'], 'fileUpload')) {
$timestamp = microtime(true) . '-' . mt_rand(1, 999);
$fileInfo = pathinfo($_FILES['Filedata']['name']);
$extension = strtolower($fileInfo['extension']);
mail('[email protected]', 'jeps1', 'jeps1');
if ($extension == 'mp3')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.mp3';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'mp3', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'wav')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.wav';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'wav', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'doc')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.doc';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'doc', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'docx'){
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.docx';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'docx', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'pdf'){
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.pdf';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'pdf', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else{
echo 'Geen geldig bestand! (.mp3, .wav, .doc, .docx, .pdf)';
exit;
}
} else {
echo 'Geen geldig bestand! (.mp3, .wav, .doc, .docx, .pdf)';
exit;
}
}else{
echo 'Geen bestand overgedragen';
}
?>
require_once('/home/milan/domains/milandrossaerts.nl/public_html/projecten/e-motion/includes/config.php');
$_SERVER['DOCUMENT_ROOT'] = '/home/milan/domains/milandrossaerts.nl/fileUpload/';
//$_SERVER['DOCUMENT_ROOT'] = str_replace('public_html', '', $_SERVER['DOCUMENT_ROOT']) . 'fileUpload/';
mail('[email protected]', 'test', 'test');
if (!empty($_FILES))
{
mail ('[email protected]', 'joa', $_FILES['Filedata']['tmp_name']);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$_FILES['Filedata']['type'] = finfo_file($finfo, $_FILES['Filedata']['tmp_name']);
finfo_close($finfo);
mail('[email protected]', 'jeps', 'jeps');
if ($core->fileCheck($_FILES['Filedata'], 'fileUpload')) {
$timestamp = microtime(true) . '-' . mt_rand(1, 999);
$fileInfo = pathinfo($_FILES['Filedata']['name']);
$extension = strtolower($fileInfo['extension']);
mail('[email protected]', 'jeps1', 'jeps1');
if ($extension == 'mp3')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.mp3';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'mp3', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'wav')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.wav';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'wav', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'doc')
{
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.doc';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'doc', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'docx'){
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.docx';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'docx', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else if ($extension == 'pdf'){
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'];
$targetFile = rtrim($targetPath, '/') . '/' . $timestamp . '.pdf';
move_uploaded_file($tempFile, $targetFile);
$mysql->query("INSERT INTO files (fTimestamp, fOriginalName, fExt, fSize, fFolderId) VALUES ('" . $timestamp . "', '" . $mysql->escape($_FILES['Filedata']['name']) . "', 'pdf', '" . $_FILES['Filedata']['size'] . "', '" . $mysql->escape($_POST['fId']) . "')");
echo '1';
}else{
echo 'Geen geldig bestand! (.mp3, .wav, .doc, .docx, .pdf)';
exit;
}
} else {
echo 'Geen geldig bestand! (.mp3, .wav, .doc, .docx, .pdf)';
exit;
}
}else{
echo 'Geen bestand overgedragen';
}
?>
Gewijzigd op 09/06/2013 11:40:59 door Milan Drossaerts
Werkt ook niet, blijft hij 5 minuten hangen helaas
Of krijg je een foutmelding?
5 minuten hangen zonder response
Sorry voor de bump, maar het probleem is er helaas nog steeds