我似乎无法在我的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
)
答案 0 :(得分:4)
isset应根据您的输出检查formFile-inputEl。
if (!isset($_FILES['formFile-inputEl'])) {
}