-
Notifications
You must be signed in to change notification settings - Fork 1
/
processform.php
51 lines (43 loc) · 1.28 KB
/
processform.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
<?php
// change this to your temp path
$upload_dir = "./tmp/pptxImport/";
$upload_file = $upload_dir . basename($_FILES['thefile']['name']);
$pptxFile = $_FILES['thefile']['name'];
if (copy($_FILES['thefile']['tmp_name'], $upload_file))
{
echo "Success on Import!";
echo "<p>File Name: " . $pptxFile . "</p>";
function pptx_to_text ($input_file)
{
$zip_handle = new ZipArchive();
$output_text = "";
if(true === $zip_handle->open($input_file))
{
$slide_number = 1; // loop trough number of slides in the pptx file
while(($xml_index = $zip_handle->locateName("ppt/slides/slide".$slide_number.".xml")) !== false)
{
$xml_datas = $zip_handle->getFromIndex($xml_index);
$xml_handle = DomDocument::load($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
$output_text .= strip_tags($xml_handle->saveXML());
$slide_number++;
}
if ($slide_number == 1)
{
$output_text .= "";
}
$zip_handle->close();
}
else
{
$output_text .= "There was an error, couldn't open the file";
}
return $output_text;
}
echo pptx_to_text($upload_dir . $pptxFile);
}
else // throw error
{
echo "There was an error while processing the file!";
print_r($_FILES);
}
?>