Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery文件上传不';t工作:PHP jQuery-缺少正确的依赖项_Php_Jquery_Mysql_Jquery File Upload - Fatal编程技术网

jQuery文件上传不';t工作:PHP jQuery-缺少正确的依赖项

jQuery文件上传不';t工作:PHP jQuery-缺少正确的依赖项,php,jquery,mysql,jquery-file-upload,Php,Jquery,Mysql,Jquery File Upload,嗨,我喜欢的外观,但它的疯狂是多么困难,以消除绒毛代码从良好的位。。它似乎有意强迫我的东西进入工作状态 简单地说,当它不是我代码的一部分时,它会工作,但当我在代码之外实现它时,它会中断 例如: html示例中充满了我不想/不能在实际代码中使用的外部url引用。当我把它切下来,试图把它倾出来时,它会破裂,有太多的东西要倒进去 对于一个知道自己想要什么的实际开发人员来说,文档一开始就太“深入”了——没有“简单”的示例,有基于假设您的上下文的“假设”示例 有人能帮我写一个index.php吗?它告诉

嗨,我喜欢的外观,但它的疯狂是多么困难,以消除绒毛代码从良好的位。。它似乎有意强迫我的东西进入工作状态

简单地说,当它不是我代码的一部分时,它会工作,但当我在代码之外实现它时,它会中断

例如:

  • html示例中充满了我不想/不能在实际代码中使用的外部url引用。当我把它切下来,试图把它倾出来时,它会破裂,有太多的东西要倒进去
  • 对于一个知道自己想要什么的实际开发人员来说,文档一开始就太“深入”了——没有“简单”的示例,有基于假设您的上下文的“假设”示例
  • 有人能帮我写一个index.php吗?它告诉我如何以尽可能简单和轻松的方式将一个实际的php文件定位到我放置的位置,发送什么参数(对于后续的数据库更新,我可能会这样做),在设置中指定上传目录的位置,如何隐藏任何“正常”操作。。第一原则总是最好的,但它们是不存在的
  • 简单地说:我想用jQuery file upload的漂亮gui版本替换普通的“file_upload”htmlform场景,但这太难了
真正的代码位在哪里

在我接受讲座之前,这是我在大约9个月内第三次或第四次尝试实现此功能,每次安装约4小时后我都停止了。每次我都会退后一步,选择一些不那么漂亮但我可以控制的东西

        <!-- Force latest IE rendering engine or ChromeFrame if installed -->
        <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <![endif]-->

        <!-- Generic page styles -->
        <link rel="stylesheet" href="../common/jQuery-File-Upload_8.7.1/css/style.css">
        <!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
        <link rel="stylesheet" href="../common/jQuery-File-Upload_8.7.1/css/jquery.fileupload-ui.css">

        <div class="container">

            <!-- The file upload form used as target for the file upload widget -->
            <form id="fileupload" action="//jquery-file-upload.appspot.com/" method="POST" enctype="multipart/form-data">

                <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                <div class="row fileupload-buttonbar">
                    <div class="span7">
                        <!-- The fileinput-button span is used to style the file input field as button -->
                        <span class="btn btn-success fileinput-button">
                            <i class="icon-plus icon-white"></i>
                            <span>Add files...</span>
                            <input type="file" name="files[]" multiple>
                        </span>
                        <button type="submit" class="btn btn-primary start">
                            <i class="icon-upload icon-white"></i>
                            <span>Start upload</span>
                        </button>
                        <button type="reset" class="btn btn-warning cancel">
                            <i class="icon-ban-circle icon-white"></i>
                            <span>Cancel upload</span>
                        </button>
                        <button type="button" class="btn btn-danger delete">
                            <i class="icon-trash icon-white"></i>
                            <span>Delete</span>
                        </button>
                        <input type="checkbox" class="toggle">
                        <!-- The loading indicator is shown during file processing -->
                        <span class="fileupload-loading"></span>
                    </div>
                    <!-- The global progress information -->
                    <div class="span5 fileupload-progress fade">
                        <!-- The global progress bar -->
                        <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                            <div class="bar" style="width:0%;"></div>
                        </div>
                        <!-- The extended global progress information -->
                        <div class="progress-extended">&nbsp;</div>
                    </div>
                </div>
                <!-- The table listing the files available for upload/download -->
                <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
            </form>
            <br>            
        </div>
        <!-- The blueimp Gallery widget -->
        <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
            <div class="slides"></div>
            <h3 class="title"></h3>
            <a class="prev">‹</a>
            <a class="next">›</a>
            <a class="close">×</a>
            <a class="play-pause"></a>
            <ol class="indicator"></ol>
        </div>
        <!-- The template to display files available for upload -->
        <script id="template-upload" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-upload fade">
                <td>
                    <span class="preview"></span>
                </td>
                <td>
                    <p class="name">{%=file.name%}</p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <p class="size">{%=o.formatFileSize(file.size)%}</p>
                    {% if (!o.files.error) { %}
                        <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                    {% } %}
                </td>
                <td>
                    {% if (!o.files.error && !i && !o.options.autoUpload) { %}
                        <button class="btn btn-primary start">
                            <i class="icon-upload icon-white"></i>
                            <span>Start</span>
                        </button>
                    {% } %}
                    {% if (!i) { %}
                        <button class="btn btn-warning cancel">
                            <i class="icon-ban-circle icon-white"></i>
                            <span>Cancel</span>
                        </button>
                    {% } %}
                </td>
            </tr>
        {% } %}
        </script>
        <!-- The template to display files available for download -->
        <script id="template-download" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-download fade">
                <td>
                    <span class="preview">
                        {% if (file.thumbnailUrl) { %}
                            <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                        {% } %}
                    </span>
                </td>
                <td>
                    <p class="name">
                        <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                    </p>
                    {% if (file.error) { %}
                        <div><span class="label label-important">Error</span> {%=file.error%}</div>
                    {% } %}
                </td>
                <td>
                    <span class="size">{%=o.formatFileSize(file.size)%}</span>
                </td>
                <td>
                    <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                        <i class="icon-trash icon-white"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" name="delete" value="1" class="toggle">
                </td>
            </tr>
        {% } %}
        </script>

        <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.iframe-transport.js"></script>
        <!-- The basic File Upload plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.ui.widget.js"></script>
        <!-- The basic File Upload plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload.js"></script>
        <!-- The File Upload processing plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-process.js"></script>
        <!-- The File Upload image preview & resize plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-image.js"></script>
        <!-- The File Upload audio preview plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-audio.js"></script>
        <!-- The File Upload video preview plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-video.js"></script>
        <!-- The File Upload validation plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-validate.js"></script>
        <!-- The File Upload user interface plugin -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/jquery.fileupload-ui.js"></script>
        <!-- The main application script -->
        <script src="../common/jQuery-File-Upload_8.7.1/js/main.js"></script>
        <!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
        <!--[if (gte IE 8)&(lt IE 10)]>
        <script src="../common/jQuery-File-Upload_8.7.1/js/cors/jquery.xdr-transport.js"></script>
        <![endif]-->

添加文件。。。
开始上传
取消上传
删除

{% } %}

{%if(file.error){%} 错误{%=file.Error%} {% } %} {%=o.formatFileSize(file.size)%} 删除 {% } %}
所以我用这把头发拔了一个多星期,我感觉到了你的痛苦。不过我还是设法找到了一些有用的信息,我正计划在某个地方写一篇关于这方面的按部就班的文章/博客文章,因为我很难找到很多有用的信息

我最终是如何正确地实现这一点的,是通过实现基本插件,并手动构建用户界面的其余部分。我的要求是多文件上传,每次上传都有额外的表单字段

在使用基本插件时,请确保节省时间,并获取他们在UI版本中使用的模板引擎(您提到的一个外部URL引用),因为它确实有助于为每次上载加载模板

您需要的JS文件如下所示:

array(1) {
  ["files"]=>
  array(5) {
    ["name"]=>
    array(1) {
      [0]=>
      string(12) "6a19440e.mp4"
    }
    ["type"]=>
    array(1) {
      [0]=>
      string(9) "video/mp4"
    }
    ["tmp_name"]=>
    array(1) {
      [0]=>
      string(23) "C:\xampp\tmp\phpEED.tmp"
    }
    ["error"]=>
    array(1) {
      [0]=>
      int(0)
    }
    ["size"]=>
    array(1) {
      [0]=>
      int(6068582)
    }
  }
}
  • jquery.ui.widget.js
  • jquery.iframe-transport.js
  • jquery.fileupload.js
  • tmpl.min.js(如果您计划使用模板引擎)
以下是我上传文件的html:

<div class="row-fluid">
    <input type="file" name="files[]" id="fileupload" multiple="multiple" data-url="uploader.php"/>
</div>

<!-- the file uploads will be shown here -->
<div id="uploads" class="row-fluid"></div>

<!-- template for each file being uploaded -->
<script type="text/x-tmpl" id="upload-template">
    <div class="span4" style="padding: 10px;">
        <div class="preview"></div>

        <div class="control-group">
            <label class="control-label" for="title">{$lang.video}</label>
            <div class="controls">
                <input type="text" name="title" value="{%=o.title%}"/>
            </div>
        </div>

        <div class="control-group">
            <div class="controls">
                <button class="btn btn-primary start">
                    <i class="icon-upload"></i>
                    <span>start upload</span>
                </button>
                <button class="btn btn-warning cancel">
                    <i class="icon-remove"></i>
                    <span>cancel</span>
                </button>
            </div>
        </div>
    </div>
</script>

文件上载的其余部分您将正常处理。这对我来说仍然是一项正在进行的工作。一旦我完成了这个实现,我会根据请求更新到一个完全工作的脚本。

也许会更新到插件,这样人们就知道你的意思了。我也想实现这一点,但因为它太复杂了,我选择了。不是说BlueImp不好,我个人就是无法让它工作。好吧,很抱歉,这是一个
标签
,所以我认为没有必要链接它-我会让你得到你支付的东西。另一个选择是。Fine Uploader由库的实际开发人员(而不是随机用户)支持。本周每天都在进行大量的开发,为未来计划了大量的功能。不太确定“花钱买什么”提到:你是在暗示我忘恩负义吗?好主意实施不力就是我要说的:-)你有没有看过这篇文章?:-)不幸的是,现在还没有,我认为没有太多的兴趣。如果你正在为某些特定的东西而挣扎,我可以尝试帮助你。我想要一个精简的实现,包括需要的js.files/css,如何通过一些jQuery/markup实现它,以及它在哪里设置目标php文件,如果它的行数超过一手,那就太乱了
array(1) {
  ["files"]=>
  array(5) {
    ["name"]=>
    array(1) {
      [0]=>
      string(12) "6a19440e.mp4"
    }
    ["type"]=>
    array(1) {
      [0]=>
      string(9) "video/mp4"
    }
    ["tmp_name"]=>
    array(1) {
      [0]=>
      string(23) "C:\xampp\tmp\phpEED.tmp"
    }
    ["error"]=>
    array(1) {
      [0]=>
      int(0)
    }
    ["size"]=>
    array(1) {
      [0]=>
      int(6068582)
    }
  }
}