我最近玩过 linphone,我成功地将它与我自己的服务器集成以进行通话和短信,但是我正在尝试配置发送图像,但它根本不起作用。我在自己的服务器上获取用于文件上传的 .php 文件,并将共享图像服务器从 linphone 指向它,但它不会向服务器发送任何参数。
问问题
2099 次
2 回答
1
好的,这是原始 PHP 文件 - https://wiki.linphone.org/wiki/index.php/Liblinphone:file_transfer
<?php
date_default_timezone_set("UTC");
if (count($_FILES) != 0) {
$uploaddir = dirname(__FILE__).'/tmp/';
$rcvname=$_FILES['File']['name'];
//$ext= strtolower(pathinfo($rcvname, PATHINFO_EXTENSION));
//$allowed_ext = array("jpg", "txt", "zip", "zlib", "gz");
if (!in_array($ext, $allowed_ext)) $ext="jpg";
$tmpfile=$_FILES['File']['tmp_name'];
error_log('Uploaded '.$rcvname.' to '.$tmpfile."\n", 3, "/var/log/trace_file_sharing.log");
//$uploadfile = $uploaddir.time().md5_file($tmpfile).".".$ext;
$uploadfile = $uploaddir.uniqid()."_".bin2hex(openssl_random_pseudo_bytes(10)).".$ext";
if (move_uploaded_file($tmpfile, $uploadfile)) {
error_log('Moved to '.$uploadfile."\n", 3, "/var/log/trace_file_sharing.log");
$ipport = $_SERVER['HTTP_HOST'];
$prefix= (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"])=="on")?"https":"http";
$start= $prefix."://".$ipport.dirname($_SERVER['REQUEST_URI']);
$http_url = $start."/tmp/".basename($uploadfile);
// validity time is one week ahead from now
$until = date("Y-m-d\TH:i:s\Z",time()+7*24*60*60);
echo '<?xml version="1.0" encoding="UTF-8"?><file xmlns="urn:gsma:params:xml:ns:rcs:rcs:fthttp">
<file-info type="file">
<file-size>'.$_FILES['File'][size].'</file-size>
<file-name>'.$_FILES['File'][name].'</file-name>
<content-type>'.$_FILES['File'][type].'</content-type>
<data url = "'.$http_url.'" until = "'.$until.'"/>
</file-info>
</file>';
}
}
if ((count($_POST) == 0) && (count($_FILES) == 0)) {
if (!function_exists('http_response_code')) {
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
header($protocol . ' 204 No Content');
$GLOBALS['http_response_code'] = 204;
} else {
http_response_code(204);
}
}
?>
只是复制粘贴,它的工作。
它将这个 xml 文档发送/应答给另一个使用 linphone 的用户。
<?xml version="1.0" encoding="UTF-8"?><file xmlns="urn:gsma:params:xml:ns:rcs:rcs:fthttp">
<file-info type="file">
<file-size>64475</file-size>
<file-name>25756.jpg</file-name>
<content-type>image/jpeg</content-type>
<data url = "http://xxx.xxx.xxx./path/file.jpg" until = "2015-11-18T20:13:00Z"/>
</file-info>
</file>
如果你想让它与 Asterix 兼容,你需要实现正确的答案,如 xml 文档或只是发送 echo "Photo'.$http_url.'"
(这适用于 Jitsi)..
于 2015-12-11T20:17:26.350 回答
0
来自这里的示例http://osdir.com/ml/linphone-developers-sip-voip/2013-08/msg00003.html
<?php
function getExtension($str)
{
$i = explode('.', $str);
return strtolower(end($i));
}
if ($_FILES["userfile"]["error"] > 0)
{
return;
}
else
{
$size = ($_FILES["userfile"]["size"] / 1024);
if($size > 1000)
{
return;
}
$locdir = dirname(__FILE__);
$globdir = "http://192.168.91.101/userdata";
$uploaddir = '/images/' . date('Y-m-d') . '/';
if (!is_dir($uploaddir)) {
mkdir($uploaddir, 0777);
}
$uploadfile = $uploaddir . uniqid() . '.' . getExtension($_FILES["userfile"]["name"]);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $locdir . $uploadfile))
{
echo $globdir . $uploadfile;
}
}
?>
于 2015-12-11T11:40:45.540 回答