unoconv doc convert to pdf code prob
Posted on
16th Feb 2014 07:03 pm by
admin
PHP/5.3.1
Hi. I am trying to use this code to convert docs to .pdf utilizing unoconv. However the page just freezes blank, with no php errors reported. All permissions to folders are set 777. Can anyone see why this code may be failing??? Thanks in advance.
Code: <?php require_once('../Connections/stuff.php'); ?>
<?php
/* Global Setting */
$unoconv_path = "/usr/share/doc";
mysql_select_db('stuff');
/* ------------ */
/* tmp directory to do processing */
if(!is_dir("/tmp")){
mkdir("/tmp", 0755);
}
// chmod("tmp/", 0755);
/* ---------------- */
$inputfile = $_FILES["file"];
$arr=explode(".",$inputfile['name']);
$extension=$arr[1];
$name=$inputfile['name'];
$tmpname=$inputfile['tmp_name'];
/*copying uploaded file to tmp*/
copy($tmpname,"/tmp/$name");
/* ---------------- */
if(isset($_GET['AttractID'])) {
/*if we have pdf file input*/
$newdir=$_GET['AttractID'];
if($extension=="pdf")
{
/* create directory of user*/
if(!is_dir("../User_Files/Attractions/".$newdir)){
mkdir("../User_Files/Attractions/".$newdir, 0755);
}
// chmod("../User_Files/Attractions/".$newdir, 0755);
/* ---------------- */
copy("tmp/".$inputfile['name'],"../User_Files/Attractions/".$newdir."/".$inputfile['name']);
$query = "INSERT INTO attract_res values(NULL,'".$newdir."','".$newdir."/".$inputfile['name']."')";
mysql_query($query);
}
/* ---------------- */
if(($extension=="doc"||$extension=="docx"||$extension=="odt"||$extension=="odp"||$extension=="html"||$extension=="rtf"||$extension=="txt"||$extension=="ppt"||$extention =="ltx") && isset($unoconv_path))
{
$unocommand=$unoconv_path . "/unoconv";
if(!file_exists($unocommand))
{
exit("Unoconv executable not found at '$unoconv_path'");
}
shell_exec($unocommand . " --format=pdf tmp/".$inputfile['name']);
if(!is_dir("../User_Files/Attractions/".$newdir)){
mkdir("../User_Files/Attractions/".$newdir, 0755);
}
// chmod("../User_Files/Attractions/".$newdir, 0755);
$newfile = $arr[1]."pdf";
copy("tmp/".$newfile, "../User_Files/Attractions/".$newdir."/".$newfile);
$query = "INSERT INTO attract_res values(NULL,'".$newdir."','".$newdir."/".$inputfile['name']."')";
mysql_query($query);
}
}
/* ---------------- */
/* Empty tmp directory*/
$files = glob("tmp/*.*",GLOB_NOSORT);
foreach($files as $name) unlink($name);
// chmod("tmp/", 0755);
/* ---------------- */
?>
No comments posted yet
Your Answer:
Login to answer
257
10
Other forums
Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba
text box alphanumeric caracters only
hi all!
I have search on google on how to enter in a test box only caracters A-Z,a-z,0-9 usi
Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,
ALV sum various columns problem
Hi all,
I'm doing a report on ABAP for a timesheet of the current month. The output i want is s
file_put_contents and createimagefromjpeg
All,
I do somethings and then I have the following code:
file_put_contents('./test/'.$filename
Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I
if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough
problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin
Alternate messaging
I have 4 strings in MySQL db1
$string1 : Hello
$string2 : Hi
$string3 : Great
$strin
strtotime issue
Hey all,
I'm playing around with some code, and basically the idea is:
Person changes