pas geleden zelf gemaakt
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
| <form action='upload.php' method=post enctype='multipart/form-data'>
<input type='hidden' name='action' value='upload'>
Bestand: <input type='file' name='filename'>
<input type='submit' value='Upload File'>
</form>
<?
if ($action == 'upload')
{
$filename = $_FILES["filename"]["name"];
$doc = array('doc', 'rtf', 'txt', 'wpd', 'wri', 'wps');
// welke bestands extenties zijn toegestaan
$fileparts = explode(".", strrev($filename), 2);
$name = strrev($fileparts[1]);
$ext = strrev($fileparts[0]);
unset($fileparts);
if ( in_array(strtolower($ext), $doc) ) {
if ($_FILES["filename"]["size"] > $max_size) die ("<b>Bestand te groot!<br>Probeer het opnieuw met een kleinere file!</b>");
else {
copy($_FILES["filename"]["tmp_name"],"./temp/".$_FILES["filename"]["name"]) or die("<b>Unknown error!</b>");
$word = new COM("word.application") or die("Unable to instanciate Word");
//word openen
$word->Visible = 0;
// onzichtbaar maken van word
$word->Documents->Open("C:\webdir" . Chr(92) . "temp" . Chr(92) . $_FILES["filename"]["name"]);
//openen van dir "C:\webdir\temp"
$word->Documents[1]->SaveAs("C:\webdir" . Chr(92) . "temp" . Chr(92) . "txt" . Chr(92) . $_FILES["filename"]["name"],2);
//opslaan in dir "C:\webdir\temp\txt"
$word->Quit();
$word->Release();
$word = null;
$handle = fopen("C:\webdir" . Chr(92) . "temp" . Chr(92) . "txt" . Chr(92) . $_FILES["filename"]["name"],"r");
//openen van "C:\webdir\temp\txt"
$txt = fread($handle, filesize("C:\webdir" . Chr(92) . "temp" . Chr(92) . "txt" . Chr(92) . $_FILES["filename"]["name"]));
fclose($handle);
$txt = addslashes($txt);
$db = mysql_connect("localhost","user","pass");
mysql_select_db("db", $db) or die ("Fout: openen database mislukt");
mysql_query("INSERT INTO ... ") or die("MySQL Error: " . mysql_error());
}
}
}
?> |
even uitleg:
$word->Documents[1]->SaveAs("C:\\blaat.txt",
2);
doc=0, dot =1, txt=
2, htm=8, asc=9, wri=13, doc (word perfect DOS)=24, wps (works)=28
[
Voor 112% gewijzigd door
krvabo op 28-04-2004 03:41
]
Pong is probably the best designed shooter in the world.
It's the only one that is made so that if you camp, you die.