Hi everyone,
i am wondering how to be able to upload a file using extjs, php and a mysql db...
I have a form(called register) with several fields, one of them happens to be a FileUploadField (i want to upload a picture associated to the form).
Anyway, when i submit my form i launch the following function :
function create(){
Ext.Ajax.request({
waitMsg: 'Please wait...',
url: 'registration.php',
action:'submit',
params: {task: "create" , name:form_name.getValue(), lastname:form_lastname.getValue(),picture:form_pic ture.getValue()}, Does posting my photo of a book cover violate :: If a particular website addresses this issue, I would appreciate that . [8] If a photographer were to upload this kind of photo, some tangible print http://answers.google.com/answers/threadview?id=356201HOME |
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
Ext.MessageBox.alert('Congratulations','You are ow registered');
register.getForm().reset();
break;
default:
Ext.MessageBox.alert('Warning','warning');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('error','could not connect to the database. retry later');
}
});
}
The thing is that i get well the name of the picture, but not the picture itself, it doesn't seem to be transfered to my server...
I am sure i am wrong around this getValue() thing, but i don't know how to solve it...
Anyone to give me a hand please ?
Thanks
The thing is that i don't know how to combine the register.getForm().submit() and to pass some parameters in the function as : Point of sale system comparisons:: with Accounting software and then upload to Headquarters. At issue is not which applications to computerize; the foodservice industry has outgrown the http://answers.google.com/answers/threadview/id/211212.htmlHOME |
params :{task :"create", date_added:form_date_added.getValue().format('Y-m-d')}
could you give me an example please ?
(light) working php to upload an image - you figure out how to insert it into your db.
$target_path = "images/";
$fileName = basename( $_FILES['image']['name']);
$target_path = $target_path .$fileName;
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
echo "{success: true, imgPath : '" . $target_path . "', fileName : '$fileName'}";
}
else{
echo "{ success: false, msg : 'There was an error!'}";
}
?>
try fileUpload : true on your form and use the form's submit method.
This is an upload panel that uses the Ext file upload field (see examples for the source)
ImageUploadPanel = function (config) {
var win;
var form;
var previewPanel;
var fileField;
return {
init : function(config) {
fileField = new Ext.form.FileUploadField({
width : 350,
emptyText : 'Select an image',
fieldLabel : 'Image',
name : 'image',
buttonCfg : {
text : '',
iconCls : 'upload-icon'
},
listeners : {
fileselected : {
scope : this,
fn : this.submit
}
},
getValue : function() {
return(this.manualValue);
}
});
if (! win) {
form = new Ext.form.FormPanel({
fileUpload : true,
labelWidth : 50,
height : 50,
width : 475,
region : 'north',
border : false,
bodyStyle : 'padding: 10px; background-color: #DFE8F6',
items : fileField
});
previewPanel = new Ext.Panel({
html : 'preview area',
region : 'center',
width : 475,
autoScroll : true,
bodyStyle : 'padding: 10px; background-color: #DFE8F6',
border : false
});
win = new Ext.Window({
width : 500,
height : 400,
layout : 'border',
title : 'Please Select an image to upload.',
border : false,
resizable : false,
movable : false,
modal : true,
closeAction : 'hide',
autoScroll : true,
items : [
form,
previewPanel
],
buttons : [
{
text : 'Save',
handler : function() {
//console.info('fileField.getValue() = ' + fileField.getValue());
this.saveCallback(fileField.getValue());
this.hide.defer(100);
},
scope : this
},
{
text : 'Cancel',
handler : this.hide,
scope : this
}
]
});
}
},
show : function(config) {
config = config {};
this.init(config);
this.saveCallback = config.saveCallback Ext.emptyFn;
win.show();
if (config.reset) {
this.reset();
}
},
hide : function() {
win.hide();
},
reset : function() {
form.getForm().reset();
previewPanel.body.update('Please upload an image.');
},
submit : function() {
win.el.mask('please wait...', 'x-mask-loading');
form.form.submit({
url : 'imageUploader.php',
success : function(form, result) {
//console.info(result);
fileField.manualValue = result.result.fileName;
previewPanel.body.fadeOut({
callback : function() {
win.el.unmask();
Ext.MesssageBox.alert(result.result.fileName);
}
});
},
failure : function(form, result) {
win.el.unmask('please wait...', 'x-mask-loading');
previewPanel.body.update('Please upload an interaction process PNG, JPG or GIF.');
},
scope : this
});
}
}
}();
So are the fields all children of the same form?
are they all in one form?
Heres my question?
Why would someone get bored with doing IT for 10 years?
|