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
multiple recipients + dbuser mail recall
Hello,
I am building a php login script.
When the user registers the script will send
Problem with php's rename function
So, i'm having a problem with the php rename function. Basically my script 'delete_user.php' attempt
Multiple submit forms inside a mysql array page
Hi all,
Im having trouble to get the beneath script to work the thing i can't seem to get wor
AutoChoosing a CSS file based on URL
Hey everyone,
I have a site that has multiple URLs and CSS files.
Based on the URL tha
Remote Database Access
Hey guys!!
OK, i'm used to only working with databases from the CPANEL, accessing phpMyAdmin
textfield unchanged
hi,
i want my form to know whether its textbox is unchange or not.
if($textbox == 'unchang
login form can you find my error?
registrationform.php seems fine send data to registration.php
registration.php seems fine checks
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect
How to copy a part of a vector in a raw memory
Hi,
How can I copy a part of a vector into a memory:
1
2
3
4
5
Developing Ajax-enabled ASP.Net applications for the iPhone
I would like to develop Ajax web applications using Visual Studio that are optimized for the iPhone.