1
我在EXTJS(http://dev.sencha.com/deploy/dev/examples/form/file-upload.html)中使用UploadFile示例,並且出現錯誤。EXTJS&PHP上傳文件2
ExtJS的:
var loadfile = new Ext.FormPanel({
fileUpload: true,
width: 500,
frame: true,
title: 'Добавить фотографию',
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [
{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Выберите фотографию',
fieldLabel: 'Фото',
name: 'userfile',
buttonText: 'Открыть'
}],
buttons: [{
text: 'Сохранить',
handler: function(){
if(loadfile.getForm().isValid()){
//alert('Имя: '+loadfile.getForm().findField('userfile').getValue());
loadfile.getForm().submit({
url: '/test/file-upload.php',
waitMsg: 'Сохранение фотографии...',
success: function(loadfile, o){
msg('Success', 'Processed file "'+o.result.file+'" on the server');
}
});
}
}
},{
text: 'Сброс',
handler: function(){
loadfile.getForm().reset();
}
}]
});
文件upload.php的:
$uploaddir = '/var/lib/tomcat6/webapps/test/upload/000'//.$_GET["path"];
if (!is_dir($uploaddir))
{
mkdir($uploaddir, 0777);
}
$uploaddir.='/';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir .
$_FILES['userfile']['name'])) {
echo $uploaddir;
} else {
echo "error";
}
和我在EXT-all.js錯誤:
Uncaught SyntaxError: Unexpected token <
我資助這個:「
」 – user15445看起來你的服務器沒有處理PHP,只是將它作爲純文本返回。你確定mod_php是在apache中啓用的嗎? – NDM
apache是的,但這個HTML從tomcat6開始 – user15445