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
need Array help
This is what I have to do.
$teamname[1] = "Red Sox"
$teamname[2] = "Gian
Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is
CHECH A STRING FOR ' " ' (DOUBLE QUOTES)
I am checking for delimiter (.!?) and if there is a " after a sentence then it should neglect a
How do i use vars in an array
Hiya peeps!
How do I use a var in an array. You will see $id but it isnt working.
Pop-up Banner
Hello Friends,I need to use banner in our client site.Example: www.example.com if i enter this site
If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.
i have this c
MySQL Primary key gap
Alright, so I have a table with 26 entries in it (id, filename, caption) for my image randomiser (ht
Help With editting and deleting form
So look at this image :
http://img194.imageshack.us/img194/8272/snapshot5f.png
This table
mysq_num_rows
Hi,
I want to use:
Code: if(mysql_num_rows($ergebnis2)==2)
how can the value 2, be
Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree