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
Problem with HTTP Caching...?
Hi there, im trying to implement caching. But it doesn't always work.
I post it here because ther
How to read posted binary data from a mobile device and post it to a web server?
Here is the senario...
I have a mobile device (MD) that posts binary data to a Web Server (WS
Help uploading .JPG
I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what c
Option box to change variable
Hello, i need help by making a script!
I need to write a file with option box, so a dropdown
Deleting pointers froms vector?
Hi. I have a vector filled with pointers and I want to delete the pointers. I could do a loop and do
curl javascript problem
Hi Experts.
I'm new curl and wanna to get some info from this http://www.amadeus.net/
when
array_map() probably obvious mistake
The code below is part of a class to escape strings, but should also accept an array, using array_ma
Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb
formating when pulling data from a mysql database
Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue.
I
Modal Popup Help
Hi guys, I have a modal popup with an iframe. How can i send data from a label or textbox to the ifr