Hi,
I have recently upgraded .NET from 1.0 to 1.1 and now an application I am
writing is no longer uploading the files, any ideas? I have posted the
relevant code below...
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Text" %>
<script runat="server">
void Button1_Click(object Source, EventArgs e)
{
txtMsg.InnerHtml = saveFiles();
}
string saveFiles() {
string strMessage = "";
string[] uploadArray = new string[6];
string strFileName;
string propertyPath;
string thumbnailPath;
string appPath;
string iString;
string propertyIdLocal;
string uploadPhoto1Local;
string uploadPhoto2Local;
string uploadPhoto3Local;
string uploadPhoto4Local;
string uploadPhoto5Local;
string uploadPhoto6Local;
HttpPostedFile objFile;
propertyIdLocal = MC_propertyId.Text;
appPath = Server.MapPath("../photos/");
Directory.CreateDirectory(appPath+propertyIdLocal) ;
Directory.CreateDirectory(appPath+propertyIdLocal+ "/thumbnails");
propertyPath = Server.MapPath("../photos/"+propertyIdLocal+"/");
thumbnailPath = Server.MapPath("../photos/"+propertyIdLocal+"/thumbnails/");
for (int i=0; i<Request.Files.Count; i++) {
objFile = Request.Files[i];
if (objFile.FileName != "") {
strFileName = objFile.FileName;
strFileName = strFileName.Substring(strFileName.LastIndexOf("\\" )+1);
try {
objFile.SaveAs(propertyPath+strFileName);
System.Drawing.Image image =
System.Drawing.Image.FromFile(propertyPath+strFile Name);
System.Drawing.Image thumbImage =
image.GetThumbnailImage(Convert.ToInt32(100),Conve rt.ToInt32(75),null,IntPtr.Zero);
image.Dispose();
thumbImage.Save(thumbnailPath+strFileName, ImageFormat.Jpeg);
iString = ""+i+"";
uploadArray[i] = strFileName;
strMessage+= "Uploaded: "+strFileName+"<br>";
}
catch (Exception err) {
strMessage+= "Failed uploading "+strFileName+":
"+err.ToString()+"<br>";
}
}
}
uploadPhoto1Local = uploadArray[0];
uploadPhoto2Local = uploadArray[1];
uploadPhoto3Local = uploadArray[2];
uploadPhoto4Local = uploadArray[3];
uploadPhoto5Local = uploadArray[4];
uploadPhoto6Local = uploadArray[5];
MC_propertyPhoto1Hidden.Text = uploadPhoto1Local;
MC_propertyPhoto2Hidden.Text = uploadPhoto2Local;
MC_propertyPhoto3Hidden.Text = uploadPhoto3Local;
MC_propertyPhoto4Hidden.Text = uploadPhoto4Local;
MC_propertyPhoto5Hidden.Text = uploadPhoto5Local;
MC_propertyPhoto6Hidden.Text = uploadPhoto6Local;
return strMessage;
}
....
The page returns no errors and doens't perform the 'return strMessage;' as
it used to.
Thanks for your help.