小编Pat*_*cow的帖子

如何使用Zend框架上传多个文件?

即使我选择2个或更多图像,也只会上传一个.

我有一个简单的形式:

<form action="/images/thumbs" method="post" enctype="multipart/form-data">
    <input name="file[]" id="file" type="file" multiple="" />
    <input type="submit" name="upload_images" value="Upload Images">
</form>
Run Code Online (Sandbox Code Playgroud)

然后在我的控制器中:

public function thumbsAction()
{
    $request = $this->getRequest();

    if ($request->isPost()) {
        if (isset($_POST['upload_images'])) {
            $names = $_FILES['file']['name'];

            // the names will be an array of names
            foreach($names as $name){
                $path = APPLICATION_PATH.'/../public/img/'.$name;
                echo $path; // will return all the paths of all the images that i selected
                $uploaded = Application_Model_Functions::upload($path);
                echo $uploaded; // will return true as many times as i select …
Run Code Online (Sandbox Code Playgroud)

php upload zend-framework file-upload zend-file

6
推荐指数
1
解决办法
8743
查看次数

如何返回 Elasticsearch 中字段以特定字母或多个字母开头的结果?

我有一些数据,例如

"last_name": "AA-WEST"
"last_name": "VANDER AA"
"last_name": "ARENDES-AA"
Run Code Online (Sandbox Code Playgroud)

我试图只获取以a, ie开头的名称AA-WESTARENDES-AA

我试过了

"match": {
    "last_name": {
        "query": "a",
        "operator": "and"
    }
}
Run Code Online (Sandbox Code Playgroud)

"prefix": {
    "last_name": { "value" : "a" }
}
Run Code Online (Sandbox Code Playgroud)

"match_phrase_prefix": {
    "last_name.keyword": {
        "query": "a"
    }
}
Run Code Online (Sandbox Code Playgroud)

所有这些都将返回所有名称,不仅是真正以a

有任何想法吗?

startswith elasticsearch

6
推荐指数
1
解决办法
1798
查看次数

php,如何将特殊字符转换为文本?

the_title()在这种情况下,xxxi 返回一些文本Blue &#038; Whiny

我们可以看到的问题是&字符看起来不同

如何打开Blue &#038; WhinyBlue & Whiny我tryed: ,,htmlspecialchars_decode(the_title()) 并没有什么.html_entity_decode(the_title())htmlspecialchars(the_title())

我想转换&#038;&

没有太多的代码要分享,我只是这样做:<?php the_title() ?>我得到了Blue &#038; Whiny.如果我使用get_the_title()它不会显示任何东西

有任何想法吗?谢谢

EDIT1.生病分享一些代码:

<script type="text/javascript">
function showShareUI() {

var act = new gigya.services.socialize.UserAction();
act.setUserMessage("Check out this article.");
act.setTitle("Trends on Explore Talent - <?php  the_title(); ?>");
act.setDescription("<?php  get_the_content();  ?>");
act.setLinkBack("<?php  the_permalink();  ?>");
act.addActionLink("Check out this article", "<?php the_permalink(); ?>");

var image = {
src: 'http://xxx.com/wp-content/uploads/2011/05/BOTTOM_BANNER.jpg',
href: …
Run Code Online (Sandbox Code Playgroud)

php wordpress

5
推荐指数
2
解决办法
7754
查看次数

php如何找到用户来自的位置?

简单的问题:

how to find the location (url) where a user came from before accessing my page?
Run Code Online (Sandbox Code Playgroud)

how to find the location (url) where a user goes after exiting my webpage?
Run Code Online (Sandbox Code Playgroud)

我应该从哪里开始?谢谢

php location

5
推荐指数
1
解决办法
1万
查看次数

如何在PHP中将页面重定向到https?

我有一个登录表格:

<form method =POST action="/login.php">
...
</form>
Run Code Online (Sandbox Code Playgroud)

我希望login.php页面重定向到使用https.

我不想发送用户,https://.../login.php因为他们可能会更改链接.但我想在解析登录表单数据并将用户登录之前在服务器端进行重定向.

我发现并举例:

if($_SERVER["HTTPS"] != "on") {
   header("HTTP/1.1 301 Moved Permanently");
   header("Location: "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
   exit();
}
Run Code Online (Sandbox Code Playgroud)

但我没有,$_SERVER["HTTPS"]如果我var_dump($_SERVER);

我确实有$_SERVER['SERVER_PORT']女巫是80.

有任何想法吗?

谢谢

php https redirect secure-coding

5
推荐指数
3
解决办法
2万
查看次数

在 jquery 中使用 eval 时,Uncaught SyntaxError: Unexpected token &lt; 是什么错误?

我有一个简单的ajax调用:

function message(){
    $.ajax({
        type: "GET",
        url: "/file/timestamp="+ timestamp,
        async: true,
        cache: false,
        success: function(data){
            var json = eval('('+data+')');
            console.log(json);
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

Uncaught SyntaxError: Unexpected token <在这一行收到一个错误:var json = eval('('+data+')');

有任何想法吗?

谢谢。

编辑:错误中的更多详细信息:

$.ajax.successajax.js:9
f.Callbacks.njquery.js:2
f.Callbacks.o.fireWithjquery.js:2
wjquery.js:4
f.support.ajax.f.ajaxTransport.send.d
Run Code Online (Sandbox Code Playgroud)

如果有帮助,这里有一些 php

public function fileAction()
{
    $this->getHelper('viewRenderer')->setNoRender();

    $filename = '/test/text.txt';

    $front  = Zend_Controller_Front::getInstance();
    $data   = $front->getRequest()->getParams();

    $lastModif      = !empty($data['timestamp']) ? $data['timestamp'] : 0;
    $currentModif   = filemtime($filename);

    while($currentModif <= $lastModif){
        usleep(10000);
        clearstatcache();
        $currentModif = filemtime($filename);
    }

    $response = array(); …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery syntax-error

5
推荐指数
1
解决办法
9390
查看次数

jquery怎么做翻转效果?

我试图模仿通常在你有一个面板的移动设备上找到的效果,当你点击它旋转的按钮时,在另一边它有一些其他信息.

我找到了一些使用css转换的代码,这是一个例子

js

$('#signup').on('click', function(e) {
    e.preventDefault();
    document.getElementById( 'side-2' ).className = 'flip flip-side-1';
    document.getElementById( 'side-1' ).className = 'flip flip-side-2';

});

$('#create').on('click', function(e) {
    e.preventDefault();
    document.getElementById( 'side-2' ).className = 'flip';
    document.getElementById( 'side-1' ).className = 'flip';

});
Run Code Online (Sandbox Code Playgroud)

这个例子的问题是,如果我将javascript转换为jquery,它会停止工作:

从:

 document.getElementById( 'side-2' ).className = 'flip flip-side-1';
Run Code Online (Sandbox Code Playgroud)

$( '#side-2' ).addClass('flip flip-side-1');
Run Code Online (Sandbox Code Playgroud)

此外,我不确定是否还没有一个jquery插件以更好的方式执行此操作.

有任何想法吗?

一些更多的代码.HTML

<div id="side-1" class="flip">
    <a id="signup" href="#">sign up</a>
</div>
<div id="side-2" class="flip">
    <a id="create" href="#">create</a>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.flip {
    backface-visibility:             hidden;
        -moz-backface-visibility:    hidden;
        -ms-backface-visibility:     hidden;
        -o-backface-visibility:      hidden;
        -webkit-backface-visibility: hidden; …
Run Code Online (Sandbox Code Playgroud)

javascript jquery flip jquery-effects

5
推荐指数
1
解决办法
3万
查看次数

如何在PHP中对字符串进行求和?

我有一个简单的问题:

我有这个var: $v = "24000,1500,1500,1500,1500,1500,";

我想将这些数字加在一起.

我已经尝试过str_replace,,+所以a eval(),但是没有用.

我也尝试了,str_split()但它不知道分裂,.

也许如果以某种方式将其转换为数组并做array_sum...

有任何想法吗?

谢谢

php arrays string sum

5
推荐指数
1
解决办法
1万
查看次数

phonegap + ionic使用Content-Security-Policy加载maps.googleapis.com,怎么样?

我已经尝试了许多方法加载谷歌地图和firebaseio没有成功:这就是我现在拥有的:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com;
  script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval';
  style-src 'self' 'unsafe-inline';">
Run Code Online (Sandbox Code Playgroud)

我得到:

Refused to load the script 'https://maps.googleapis.com/maps/api/js?libraries=places' because it violates the following Content Security Policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'".

Refused to load the script 'https://test.firebaseio.com/.lp?start=t&ser=79549912&cb=1&v=5' because it violates the following Content Security Policy directive: "script-src 'self' https://maps.googleapis.com/* 'unsafe-inline' 'unsafe-eval'".
Run Code Online (Sandbox Code Playgroud)

任何想法我做错了什么?

javascript google-maps phonegap-plugins firebase content-security-policy

5
推荐指数
1
解决办法
6067
查看次数

如何在PHP中使用MySQL按位运算?

我试图使用MySQL按位运算我的查询,我有这个例子:

table1
id      ptid
1       3
2       20
3       66
4       6

table2
id     types
1      music
2      art
4      pictures
8      video
16     art2
32     actor
64     movies
128    ..
...
Run Code Online (Sandbox Code Playgroud)

现在,id = 3table1'66',女巫意味着它有64 or movies2 or art

不是他也有32 or actor两次而且2 or art??

希望你看到我的困惑在哪里.我如何控制我想要的结果.在这种情况下,我想要64 or movies2 or art.

但有时我要三id'stable2属于一个idtable1

有任何想法吗?

谢谢

php mysql bitwise-operators

4
推荐指数
1
解决办法
8591
查看次数