AjaxFileUpload插件不检索$ _POST数据

这几乎是我几天前遇到的几乎相同的问题。 我当时修好了,但现在它不再工作了。 好吧,其中一些有效。

我正在使用AjaxFileUpload插件在我的WP插件中上传文件。 这个插件调用uploader.php来处理上传表单。

我能够使用$_FILES['uploadFile']获取文件名(和其他数据),但我无法检索$_POST['current_path']数据。

我有一个理论。 当我加载接口以上传数据时,隐藏的输入字段’current_path’为空(应该是)。 当我浏览我的文件夹时,使用jQuery更新隐藏的输入字段。

当我点击上传按钮时,Ajax文件上传插件会获取上传表单中的数据,并通过$_POST$_FILES将数据传递给uploader.php

但为什么我能从$_FILES而不是从$_POST获取数据?

这是我的代码:

使用Javascript

  //File upload functions // Remove feedback message on upload click jQuery('.uploadImage').live('click',function() { ajaxFileUpload(); }); (...) //Lets upload the file by using Ajax uploader plugin function ajaxFileUpload() { alert(jQuery('input[type=hidden][name=current_path]').val()) //Shows me the correct current path jQuery.ajaxFileUpload ( { url:'../wp-content/plugins/wp-filebrowser/uploader.php', secureuri:false, fileElementId:'uploadFile', dataType: 'json', success: function (data) { if(data.error != '') { alert(data.error); } else { alert(data.respons); } }, error: function (e) { jQuery('#uploadOutput').addClass('error').html('Error: ' + e).show(); }, complete: function() { // Update file list } } ) return false; } 

HTML

 
<input type="hidden" id="current_path" name="current_path" value="relative_url; ?>" /> <input type="button" class="button uploadImage" value="" />

PHP

 $this->current_path = $_POST['current_path']; $this->data['error'] = $_FILES['uploadFile']['name']; //Just for testing $this->data['respons'] = "Filename: ".$_POST['current_path']; echo json_encode($this->data); 

但为什么我能从$ _FILES而不是从$ _POST获取数据?

因为您没有提交表单,只有文件输入元素。

这似乎是插件的设计行为:

在这个被黑客入侵的版本中,它只提交输入元素的指定文件类型而不是整个表单

jQuery表单插件可以做到这两点,也许这有帮助。