我似乎无法在我的 php 文件中通过 isset($_FILES['formFile']),它总是返回 false。我正在使用 Ext js 4.1 我的目标是将这些图像存储在一个 blob 中。
extjs 代码:
var fi = new Ext.FormPanel({
fileUpload: true,
width: 400,
frame: false,
autoHeight: true,
labelWidth: 40,
border: false,
margins: '10 0 0 10',
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side',
border: false
},
items: [{
xtype: 'filefield',
emptyText: 'Select an image',
fieldLabel: 'Image',
id: 'formFile',
buttonCfg: {
text: '',
iconCls: 'upload-icon'
},
border: false
}],
buttons: [{
text: 'Upload',
handler: function(){
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'php/picture-upload.php',
waitMsg: 'Uploading your image...',
success: function(fi, o){
alert('succes');
}
});
}
}
}]
});
php:
if (!isset($_FILES['formFile'])) {
echo '<p>Please select a file</p>';
echo '{"success": false}';
} else {
try {
upload();
echo '<p>Thank you for submitting</p>';
} catch (Exception $e) {
echo $e->getMessage();
echo 'Sorry, could not upload file';
}
}
print_r($_FILES) 的输出;
Array
(
[formFile-inputEl] => Array
(
[name] => clicla.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpnUxgV3
[error] => 0
[size] => 6772
)