Ext.onReady(function() {
ulDialogTest = new Ext.Window({
layout: 'fit',
height: 100,
width: 500,
title: "Upload a Presentation",
resizable: true,
bodyBorder: false,
buttons: [{text: "Upload", handler: submitAjaxReq },
{text: "Cancel", handler: function() {ulDialogTest.hide();}}],
keys: [{key: 27, fn: function() {ulDialogTest.hide();}, scope: this}],
items: [
ulFormTest = new Ext.form.FormPanel({
id: 'ulFormID',
labelAlign: 'right',
items: [{xtype:'textfield',inputType:'file',name:'Filedata ',fieldLabel:'File'}]
})
]
});
ulDialogTest.show();
function submitAjaxReq()
{
//ulDialogTest.hide();
Ext.Ajax.request({
url: 'upload_example.php',
params: '',
method: "POST",
form: 'ulFormID',
timeout: 15000,
waitMsg:'Executing Request...',
isUpload: true,
headers: {'Content-type':'multipart/form-data'},
success: processSuccessResponse,
failure: processFailureResponse
});
//ulDialogTest.destroy();
//ulFormTest.destroy();
}
function processSuccessResponse(e){
alert('success');
alert(e.responseText);
}
function processFailureResponse(e){
alert('failure');
alert(e.responseText);
}
});
When run, i got this error : form.submit is not a function
http://localhost/ext-2.1/ext-all-debug.js
Line 5222
Beside, file is not uploaded to the server.
Thanks for help
POST http://localhost/30-5/upload_example.php500 (74ms)
I think my php was wrong. Check this for me please
if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
}
session_start();
if (!isset($_FILES["Filedata"]) !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) $_FILES["Filedata"]["error"] != 0) {
header("HTTP/1.1 500 File Upload Error");
if (isset($_FILES["Filedata"])) {
echo $_FILES["Filedata"]["error"];
}
exit(0);
}
$save_path = getcwd() . "/uploads/";
$file_name = basename($_FILES["Filedata"]['name']);
@move_uploaded_file($_FILES["Filedata"]["tmp_name"], $save_path.$file_name);
$result = array("success" => true);
echo json_encode($result);
?>
#If you have any other info about this subject , Please add it free.# |