Jan 31, 2013, 4:09 PM
Displaying a PDF uploaded to the server
Hey I am having some trouble displaying a PDF in a new window that is uploaded to the server by the client. When I try and display the copied pdf file I just get a blank window. I used the calendar demo to start with. If you want me to include all the calendar code I will, but for the I have just included the problem area. I am however able to display the pdf if I don't copy it to a new folder eg: hard code the ORIGINAL file path to the URL of the window.
Mark-up:
Mark-up:
<form runat="server">
<ext:ResourceManager runat="server" Namespace="ExchNotPOC" />
<ext:Window runat="server" ID="PDFVIEW" Hidden="true" Modal="true"/>
</form>
Java Script that calls the server: add: function (win, rec) {
var v = win.FileUp.extractFileInput().value
ExchNotPOC.direct.FileUploadTest(v);
rec.data.Url = v;
ExchNotPOC.getStore().add(rec);
ExchNotPOC.ShowMsg('Event ' + rec.data.Title + ' was added');
win.hide();
},
Code Behind: [DirectMethod]
public void FileUploadTest(string v)
{
string fileToUpLoad = v;
if(!String.IsNullOrEmpty(fileToUpLoad))
{
try
{
FileStream fs = new FileStream(@fileToUpLoad, FileMode.Open);
string fn = System.IO.Path.GetFileName(fileToUpLoad);
string saveLocation = Server.MapPath("Data") + "\\" + fn;
FileStream copied = new FileStream(@saveLocation, FileMode.Create);
fs.CopyTo(copied);
fs.Close();
copied.Close();
Ext.Net.Window win = new Ext.Net.Window();
win.FindControl("PDFVIEW");
win.Height = 500;
win.Width = 1000;
win.Loader = new ComponentLoader
{
Url = saveLocation,
Mode = LoadMode.Frame,
AutoLoad = true,
LoadMask =
{
ShowMask = true
}
};
win.Hidden = false;
win.Render(this.Form);
}
catch(Exception ex)
{
}
}
}
Thanks!