我正在使用一个 ajax 上传插件,我想将一个 textarea 并选择元素值添加到我的 FormData 类型的对象中,即data
. 我该怎么做?请帮我。
var $this = $(this);
if ( typeof upfiles[count] === 'undefined') return false;
$( document ).ready( function() {
var count = 0;
var percentComplete = 0;
var upfiles = 0;
$(".progressbar").hide();
$( '#uploadcontainer' ).on( 'upload', '#fileToUpload' , function( ) {
var $this = $(this);
if ( typeof upfiles[count] === 'undefined') return false;
var data = new FormData();
var file = upfiles[count];
data.append( 'file', file );
currfile = file.name;
fileext = currfile.substr( -3 );
if( fileext == "php" || fileext == ".js" ) {
count++;
$( '#uplcomp' ).append( 'Oopz,Error'+'<br />' + file.name + ' not an image' + '<br />' );// appending progress bar
$this.trigger('upload');
}
else
{
$.ajax({
url: 'upload.php',
type:'POST',
data: data ,