-
2 Jun 2008 07:12 PM #1
Help - FileUpload - form.submit is not a function
Help - FileUpload - form.submit is not a function
I try to make a Upload Form using ajax request. My code :
When run, i got this error :PHPコード: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);
}
});
Beside, file is not uploaded to the server.
Thanks for helpSorry for my bad English.
-
2 Jun 2008 07:30 PM #2
Why are you sending the form as an ajax request, why not just submit the form?
-
2 Jun 2008 07:44 PM #3
I'm in searching extjs. So i want to do this as a practice. I successed upload file with form submit. Can you help me resolve this. Thanks so much
Sorry for my bad English.
-
2 Jun 2008 08:16 PM #4
I changed form: 'ulFormID' to form : ulFormTest.getForm().dom i got another problem
POST http://localhost/30-5/upload_example.php500 (74ms)
I think my php was wrong. Check this for me please
PHPコード:<?php
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);
?>Sorry for my bad English.


引用して返信