日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

php linux下保存文件路径怎么写,linux下php导入带图片的word文档转为html,图片保存下来生成路径。...

發布時間:2024/9/19 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php linux下保存文件路径怎么写,linux下php导入带图片的word文档转为html,图片保存下来生成路径。... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

linux下yum install libreoffice

yum install libreoffice-headless

如果出現異常,在頁面上不一定表現出來,而是頁面卡著一直沒響應,通過apache日志看到相關錯誤[Java framework] Error in function createSettingsDocument (elements.cxx).

javaldx failed!

Warning: failed to read path from javaldx

處理為#因為用戶 www沒有HOME 會跑到root導致沒權限,可指定 export HOME=/tmp/ && 解決$shell = "export HOME=/tmp/ && /usr/bin/libreoffice --headless --convert-to html --print-to-file --printer-name nasty_lowres_printer --outdir {$_SERVER['DOCUMENT_ROOT']}/out_file/ {$full_result_path} > /dev/null 2>/dev/null &";

php如果做了函數安全過濾,需要放行shell_exec

php代碼public function upload(){

if(IS_POST){

header('Content-type: text/html; charset=UTF-8');

$reulst = upload('file');

//如果成功上傳doc,轉html

$full_result_path = $_SERVER['DOCUMENT_ROOT'].$reulst;

if(file_exists($full_result_path)){

$shell = "/usr/bin/libreoffice --headless --convert-to html --print-to-file --printer-name nasty_lowres_printer --outdir {$_SERVER['DOCUMENT_ROOT']}/out_file/ {$full_result_path}";

$doc_file_contents = shell_exec($shell);

$pattern = '/\/(\d+).html/';

preg_match_all($pattern,$doc_file_contents,$match);

if(!empty($match[0])){

$path = ($_SERVER['DOCUMENT_ROOT'].'/out_file'.$match[0][0]);

$html = file_get_contents($path);

$img_pattern = '/

preg_match_all($img_pattern,$html,$match2);

$base64_arr = $match2[2];

set_time_limit(120);

$Qiniu = new Qiniu('xxxxx','xxxxx','xxxxx');

//七牛日志

$log = [];

foreach($base64_arr as $base64){

if(strlen($base64) < 60){

$html = str_replace($base64,'',$html);

$html = preg_replace('/]*)>/i','',$html);

}else{

preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $ext_result);

$file_name = date('YmdHis').'.'. rand(10000, 99999).'.'.$ext_result[2];

$qiniukey= date("Ymd").'/doc/'.$file_name;

$status = $Qiniu->upload_file($base64,$qiniukey);

array_push($log,json_encode($status));

if($status['status']=='success'){

$status = 'http://cms3.jmcdn.cn/'.$status['key'];

$html = str_replace($base64,$status,$html);

}else{

//如果七牛保存失敗,則保存到本地 [by shw 20180709反復測試,有時候會傳七牛失敗 ,但最后幾次均全部成功,可能和網絡有關

//也可能文件名,測試也是加了隨機數文件名之后,確認下,如果還有問題則需要在這里還需要傳一次到網上,本地圖片無法主站下圖]

$new_file = "{$_SERVER['DOCUMENT_ROOT']}/out_file/".$file_name;

file_put_contents($new_file, base64_decode(str_replace($ext_result[1], '', $base64)));

$html = str_replace($base64,"/out_file/".$file_name,$html);

}

}

}$html = removeFormat($html);

echo $html;

print_r($log);die();

}else{

die('no match');

}

}else{

echo '沒有轉換文件,輸出 '.$reulst;

}

die();

}

$this->display();

}

html頁面

upload的視圖

上傳文件

function sub() {

var obj = new XMLHttpRequest();

obj.onreadystatechange = function() {

if (obj.status == 200 && obj.readyState == 4) {

var result = obj.responseText;

if(result.indexOf("upload") >-1 && result.indexOf("image") >-1){

window.opener.document.getElementById("message").innerHTML = result;

document.getElementById('con').innerHTML = "上傳成功";

document.getElementById("a1").style.display = "none";

document.getElementById("a2").style.display = "block";

}else{

document.getElementById('con').innerHTML = result;

}

}

}

// 通過Ajax對象的upload屬性的onprogress事件感知當前文件上傳狀態

obj.upload.onprogress = function(evt) {

// 上傳附件大小的百分比

var per = Math.floor((evt.loaded / evt.total) * 100) + "%";

// 當上傳文件時顯示進度條

document.getElementById('parent').style.display = 'block';

// 通過上傳百分比設置進度條樣式的寬度

document.getElementById('son').style.width = per;

// 在進度條上顯示上傳的進度值

document.getElementById('son').innerHTML = per;

}

// 通過FormData收集零散的文件上傳信息

var fm = document.getElementById('userfile3').files[0];

var fd = new FormData();

fd.append('userfile', fm);

obj.open("post", "/index.php?g=portal&m=shw&a=upload");

obj.send(fd);

}

#parent {

width: 200px;

height: 20px;

border: 2px solid gray;

background: lightgray;

display: none;

}

#son {

width: 0;

height: 100%;

background: lightgreen;

text-align: center;

}

圖片上傳

html頁面調用者

Title

function upload(){

window.open("/index.php?g=portal&m=shw&a=upload","上傳文檔","width=500,height=480,screenX=400,screenY=100");

}

非特殊說明,本博所有文章均為博主原創。

最新文章

總結

以上是生活随笔為你收集整理的php linux下保存文件路径怎么写,linux下php导入带图片的word文档转为html,图片保存下来生成路径。...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。