<bdo id='pQ8C3'></bdo><ul id='pQ8C3'></ul>
<i id='pQ8C3'><tr id='pQ8C3'><dt id='pQ8C3'><q id='pQ8C3'><span id='pQ8C3'><b id='pQ8C3'><form id='pQ8C3'><ins id='pQ8C3'></ins><ul id='pQ8C3'></ul><sub id='pQ8C3'></sub></form><legend id='pQ8C3'></legend><bdo id='pQ8C3'><pre id='pQ8C3'><center id='pQ8C3'></center></pre></bdo></b><th id='pQ8C3'></th></span></q></dt></tr></i><div id='pQ8C3'><tfoot id='pQ8C3'></tfoot><dl id='pQ8C3'><fieldset id='pQ8C3'></fieldset></dl></div>
    1. <small id='pQ8C3'></small><noframes id='pQ8C3'>

      <legend id='pQ8C3'><style id='pQ8C3'><dir id='pQ8C3'><q id='pQ8C3'></q></dir></style></legend>
      <tfoot id='pQ8C3'></tfoot>

        在 PHP 中使用 jqgrid 上传文件

        时间:2023-10-02
        <i id='ZnjK7'><tr id='ZnjK7'><dt id='ZnjK7'><q id='ZnjK7'><span id='ZnjK7'><b id='ZnjK7'><form id='ZnjK7'><ins id='ZnjK7'></ins><ul id='ZnjK7'></ul><sub id='ZnjK7'></sub></form><legend id='ZnjK7'></legend><bdo id='ZnjK7'><pre id='ZnjK7'><center id='ZnjK7'></center></pre></bdo></b><th id='ZnjK7'></th></span></q></dt></tr></i><div id='ZnjK7'><tfoot id='ZnjK7'></tfoot><dl id='ZnjK7'><fieldset id='ZnjK7'></fieldset></dl></div>

        <tfoot id='ZnjK7'></tfoot>
          <tbody id='ZnjK7'></tbody>
        <legend id='ZnjK7'><style id='ZnjK7'><dir id='ZnjK7'><q id='ZnjK7'></q></dir></style></legend>

            <small id='ZnjK7'></small><noframes id='ZnjK7'>

                • <bdo id='ZnjK7'></bdo><ul id='ZnjK7'></ul>

                  本文介绍了在 PHP 中使用 jqgrid 上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 jqgrid 实现文件上传(在 Zend 框架项目中).jqgrid 允许您创建文件"类型的输入字段,但不启用 ENCTYPE=multipart/form-data".

                  I am trying to implement file upload with jqgrid (in a Zend Framework project). jqgrid allows you to create an input field of type "file" but does not enable ENCTYPE="multipart/form-data".

                  作者推荐使用其他插件来处理文件上传,特别是Ajax File Upload.他说使用 onInitializeForm() 方法初始化它,但我不清楚具体如何做到这一点.他说,

                  The creator recommends using another plugin to handle file uploads, specifically Ajax File Upload. He says to initialize it using the onInitializeForm() method but exactly how to do this is not clear to me. He says,

                  "我建议你也可以使用 Ajax文件上传插件并初始化它仅在 onInitializeForm 事件中出现一次."

                  "Also as I suggest you can use Ajax file upload plugin and intialize it only once in onInitializeForm event."

                  这就是有关如何执行此操作的说明.

                  And that is about it for instructions on how to do this.

                  到目前为止我所做的:我有显示文件输入字段的 jqgrid 编辑表单,并且我已经准备好所有各种插件文件并正确加载.我无法弄清楚如何让提交的表单正确上传文件(我想我无法弄清楚如何使用 onInitializeForm 事件初始化 ajax 文件上传插件").任何想法都非常感谢.

                  What I have done so far: I have the jqgrid edit form displaying the file input field and I have all of the various plugin files in place and loading properly. What I cannot figure out is how to get the submitted form to properly upload the file (I guess I can't figure out how to "initialize the ajax file upload plugin with the onInitializeForm event"). Any ideas are greatly appreciated.

                  我可以让 onInitializeForm 触发一些简单的东西,比如 alert('test') 但每次加载网格时它都会触发越来越多的数字(比如,第一次什么都没有,下次加载时一个警报网格,下次有两个警报,等等).

                  For what it is worth I can get onInitializeForm to trigger something simple like alert('test') but it triggers in growing numbers each time you load the grid (like, nothing first time, one alert the next time you load the grid, two alerts the next time, etc).

                  推荐答案

                  答案如下:

                  <!-- Add your other js files like jQuery, jqGrid etc. -->
                  <script type="text/javascript" src="js/ajaxfileupload.js"></script>
                  <script language="javascript">
                      $(function() {
                          $(document).ready(function() {
                              jQuery("#your_grid_id").jqGrid({
                                  url: 'your_url',
                                  datatype: 'json',
                                  mtype: 'post',
                                  pager: 'your_pager_id',
                                  colNames: ["Description", "File"],
                                  colModel: [{name: "desc", index: "desc", ... ... ...}, {name: "file_to_upload", index: "file_to_upload", edittype: "file", ... ... ...}]
                              }).navGrid("#your_pager_id",{{... ... ...},{
                                  jqModal:true,closeAfterEdit: true,recreateForm:true,onInitializeForm : function(formid){
                                      $(formid).attr('method','POST');
                                      $(formid).attr('action','');
                                      $(formid).attr('enctype','multipart/form-data');
                                  }, afterSubmit : function(response, postdata){
                                         $.ajaxFileUpload({
                                            url: 'your_file_url_where_upload_operates', 
                                            secureuri:false,
                                            fileElementId:'file_to_upload',
                                            dataType: 'json',
                                            success: function (data, status) {
                                                alert("Upload Complete.");
                                            }
                                         });
                                     }
                                  }},{
                                  jqModal:true,closeAfterAdd: true,recreateForm:true,onInitializeForm : function(formid){
                                      $(formid).attr('method','POST');
                                      $(formid).attr('action','');
                                      $(formid).attr('enctype','multipart/form-data');
                                  }, afterSubmit : function(response, postdata){
                                         $.ajaxFileUpload({
                                            url: 'your_file_url_where_upload_operates', 
                                            secureuri:false,
                                            fileElementId:'file_to_upload',
                                            dataType: 'json',
                                            success: function (data, status) {
                                                alert("Upload Complete.");
                                            }
                                         });
                                     }
                                  }
                              });
                          });
                      });
                  </script>
                  

                  我使用 recreateForm: true 来确保在每次添加或编辑时重新创建表单.

                  I used recreateForm: true to ensure that on every Add or Edit the form is re-created.

                  如果您还有问题,请随时问我.

                  If you have problem yet, please feel free to ask me.

                  这篇关于在 PHP 中使用 jqgrid 上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Zend_Log in application.ini 下一篇:php zend gdata - 使用 oauth 获取谷歌文档列表

                  相关文章

                  最新文章

                  1. <legend id='QFzSH'><style id='QFzSH'><dir id='QFzSH'><q id='QFzSH'></q></dir></style></legend>

                    <i id='QFzSH'><tr id='QFzSH'><dt id='QFzSH'><q id='QFzSH'><span id='QFzSH'><b id='QFzSH'><form id='QFzSH'><ins id='QFzSH'></ins><ul id='QFzSH'></ul><sub id='QFzSH'></sub></form><legend id='QFzSH'></legend><bdo id='QFzSH'><pre id='QFzSH'><center id='QFzSH'></center></pre></bdo></b><th id='QFzSH'></th></span></q></dt></tr></i><div id='QFzSH'><tfoot id='QFzSH'></tfoot><dl id='QFzSH'><fieldset id='QFzSH'></fieldset></dl></div>

                  2. <small id='QFzSH'></small><noframes id='QFzSH'>

                      <tfoot id='QFzSH'></tfoot>
                        <bdo id='QFzSH'></bdo><ul id='QFzSH'></ul>