我需要检查远程服务器上是否存在特定文件.使用is_file()和file_exists()不起作用.任何想法如何快速,轻松地做到这一点?
我在项目中使用Select2来设置搜索表单中某些选择框的样式.我设法将箭头容器的渐变背景更改为黑色渐变:
.select2-container .select2-choice .select2-arrow {
background-image: -khtml-gradient(linear, left top, left bottom, from(#424242), to(#030303));
background-image: -moz-linear-gradient(top, #424242, #030303);
background-image: -ms-linear-gradient(top, #424242, #030303);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #424242), color-stop(100%, #030303));
background-image: -webkit-linear-gradient(top, #424242, #030303);
background-image: -o-linear-gradient(top, #424242, #030303);
background-image: linear-gradient(#424242, #030303);
}
Run Code Online (Sandbox Code Playgroud)
我希望箭头是白色的,但不幸的是,Select2使用背景图像作为不同的图标而不是字体 - 真棒或类似的东西,所以没有办法只用CSS改变颜色.
什么是使箭头变为白色而不是默认灰色的最简单方法?我真的要用自己的替换背景png(select2.png和select2x2.png)吗?或者有更简单的方法吗?
我的另一个问题是如何更改选择框的高度.我知道如何在打开状态下更改下拉框的高度,但我想在闭合状态下更改选择框的高度.有任何想法吗?
原始问题 我正在从ZF2控制器动作提供mp3文件.这适用于除OS X和iPhone/iPad上的Safari之外的所有浏览器.播放音频,但持续时间仅显示为NaN:NaN,而在每个其他浏览器中显示正确的持续时间.
我在SO上讨论了所有的线程,讨论了同样的问题,似乎它与响应头,特别是Content-Range和Accept-Ranges头有关.我尝试了所有不同的组合,但仍无济于事--Safari仍然拒绝正确显示持续时间.
相关的代码段如下所示:
$path = $teaserAudioPath . DIRECTORY_SEPARATOR . $teaserFile;
$fp = fopen($path, 'r');
$etag = md5(serialize(fstat($fp)));
fclose($fp);
$fsize = filesize($path);
$shortlen = $fsize - 1;
$response->setStatusCode(Response::STATUS_CODE_200);
$response->getHeaders()
->addHeaderLine('Pragma', 'public')
->addHeaderLine('Expires', -1)
->addHeaderLine('Content-Type', 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3')
->addHeaderLine('Content-Length', $fsize)
->addHeaderLine('Content-Disposition', 'attachment; filename="teaser.mp3"')
->addHeaderLine('Content-Transfer-Encoding', 'binary')
->addHeaderLine('Content-Range', 'bytes 0-' . $shortlen . '/' . $fsize)
->addHeaderLine('Accept-Ranges', 'bytes')
->addHeaderLine('X-Pad', 'avoid browser bug')
->addHeaderLine('Cache-Control', 'no-cache')
->addHeaderLine('Etag', $etag);
$response->setContent(file_get_contents($path));
return $response;
Run Code Online (Sandbox Code Playgroud)
玩家(我使用的是mediaelementjs)在Safari中看起来像这样:

我也试过根据另一个例子来解释HTTP_RANGE请求头,如下所示:
$fileSize = filesize($path);
$fileTime = date('r', filemtime($path));
$fileHandle = fopen($path, …Run Code Online (Sandbox Code Playgroud) 我是Lumen和Laravel的新手,但我必须使用Lumen编写REST API.我已经设置了一个控制器,我在使用记录器时遇到了问题.我按照文档:Lumen docs
这是我的控制器app/Http/Controllers/DocumentsController.php:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Log;
class DocumentsController extends Controller
{
public function index()
{
Log::info('test');
return response()->json(['result' => 'Oh hey!']);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行这个我收到一个错误说:
DocumentsController.php第22行中的FatalErrorException:找不到类"Log"
所以Log外观似乎有些问题(不太确定那些在Laravel/Lumen中是如何工作的).
但是,如果我更改了Log :: info()调用,要手动将日志服务从DI容器中拉出,那么它可以正常工作:
$app = app();
$app->make('log')->info('test');
Run Code Online (Sandbox Code Playgroud)
关于为什么官方文档中描述的Facade方法不起作用的任何想法?
我有一个字符串变量作为javascript中的statesData,当我在控制台中将它作为console.log(statesData)打印时,它给我输出为
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
74.987712893238,
16.4611124595779
],
[
75.0794873366632,
16.4216041790002
],
[
74.9914167945422,
16.5154363453721
],
[
74.987712893238,
16.4611124595779
]
]
]
},
"properties": {
"f1": "Bagalkot District",
"f2": 4,
"f3": 0.0327269593968744
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
75.6708769115599,
14.7838624856797
],
[
75.7046235678866,
14.7698699696418
],
[
75.7497789666211,
14.9338893073175
],
[
75.6988619436357,
14.9320185378459
],
[
75.721037483182,
14.8603111097135
],
[
75.6708769115599,
14.7838624856797
] …Run Code Online (Sandbox Code Playgroud)