Sep 23, 2010, 1:40 PM
Fileupload Controls Shows Save Dialog after upload
Hello everyone, i have a problem with the file upload functionality. I'm using the MVC pattern in my application, as far as the file upload procedure goes, it's doing what's supposed to do (it's uploading the file). The problem i'm having is after the file is uploaded to the server and then the AjaxResult returns the value. After the value is returned I get the File Download popup window, I have followed the instructions on some of the post in this Forum but they don't work for me ( I don't know why). Below you can see my code.
PropForSaleWin.ascx
PropForSale.aspx
PropForSaleWin.ascx
<ext:Window
ID="UploadFileEditor"
runat="server"
Title="Property For Sale"
Icon="House"
Width="560"
Height="450"
Modal="true"
Hidden="true"
Resizable="false">
<AutoLoad
Url="/Home/PropForSale/"
Mode="IFrame"
TriggerEvent="show"
ReloadOnEvent="true"
ShowMask="true"
MaskMsg="Loading Property Info...">
</AutoLoad>
<Buttons>
<ext:Button ID="btnTest" runat="server" Text="Save">
<Listeners>
<Click Handler="#{UploadFileEditor}.iframe.dom.contentWindow.saveInfo();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>
PropForSale.aspx
<ext:FormPanel
ID="frmFileUpload"
Title="Image Upload"
runat="server"
Frame="false"
AutoHeight="true"
MonitorValid="true"
PaddingSummary="20px 10px 0 10px"
Border="false"
LabelWidth="70"
FileUpload="true"
Url="/Data/UploadPropertyImage/">
<Items>
<ext:TextField
ID="AttachmentName"
runat="server"
FieldLabel="File Name" />
<ext:FileUploadField
ID="TheFileUploadField"
runat="server"
EmptyText="Select an image"
FieldLabel="File"
ButtonText=""
Icon="ImageAdd">
</ext:FileUploadField>
</Items>
</ext:FormPanel>
Controler Code
public AjaxResult UploadPropertyImage()
{
foreach (string file in Request.Files)
{
HttpPostedFileBase files = Request.Files[file];
string fileName = files.FileName;
if (files.ContentLength > 0)
{
string filePath = Path.Combine(@"\\formsSrv\www\prop\uploadFiles", Path.GetFileName(files.FileName));
files.SaveAs(filePath);
}
}
AjaxResult response = new AjaxResult();
response.IsUpload = true;
return response;
}
Last edited by reyonlines; Sep 23, 2010 at 4:14 PM.