我使用此脚本上传图像并使用Ajax发送数据。
<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
var formInput = $(":input,:hidden").serialize();
$('#file_upload').uploadifive({
'auto' : false,
'checkScript' : 'check-exists.php',
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>',
formInput
},
'queueID' : 'queue',
'uploadScript' : 'uploadifive.php',
'onUploadComplete' : function(file, data) { console.log(data); }
});
$('#start_upload').on('click', function () {
$('#file_upload').uploadifive('upload');
});
});
</script>
表格:
<form id="upload_document">
<input id="file_upload" name="file_upload" type="file" multiple>
<input name="form_userid" id="form_userid" type="hidden" value="<?php echo $_SESSION['userId']; ?>" />
<input type="button" id="start_upload" name="uploadenFormSend" value="Bestand(en) uploaden" class="button-pink">
</form>
当我发送表单时,$ _POST ['formInput']返回:
form_userid = 13647
但我只需要价值(13647)。我该怎么做才能实现这一目标?