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
Putting double spaces instead of single spaces
Im looking at trying to replace all single spacing between fields with double spacing
At pres
How to store checkbox array in a session, and then be able to add to it?
I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart,
Error In Syntax
I got this error:
Code: Parse error: syntax error, unexpected '>' in /home/bucket/publ
mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id
How to set pass login name from htaccess to php
When the user logs into my members page via htaccess, I'd like to retain the username so that I can
Error querying database.
I get the above error when trying to insert some values to a datatable.
Here's the code :
Compare user input to flat file data
Help...Am a complete newbie to programming so my code is prolly quite long. Am trying to verify a us
How can I Compare two xml documents?
Hi all,
I am doing a POC for my project and I am using XE database 10g version.
Rss feed question
Hi
My blog and my website are different. Am i able to take my rss feed
from my blog and p
$get problem
Hi Guys ...
can you please tell me what i am doing wrong here
Code: <?php