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="Syst em.IO" %>
<%@ Import Namespace="Syst em.Drawing" %>
<%@ Import Namespace="Syst em.Drawing.Imag ing" %>
<%@ Import Namespace="Syst em.Text" %>
<script runat="server">
void Button1_Click(o bject Source, EventArgs e)
{
txtMsg.InnerHtm l = saveFiles();
}
string saveFiles() {
string strMessage = "";
string[] uploadArray = new string[6];
string strFileName;
string propertyPath;
string thumbnailPath;
string appPath;
string iString;
string propertyIdLocal ;
string uploadPhoto1Loc al;
string uploadPhoto2Loc al;
string uploadPhoto3Loc al;
string uploadPhoto4Loc al;
string uploadPhoto5Loc al;
string uploadPhoto6Loc al;
HttpPostedFile objFile;
propertyIdLocal = MC_propertyId.T ext;
appPath = Server.MapPath( "../photos/");
Directory.Creat eDirectory(appP ath+propertyIdL ocal);
Directory.Creat eDirectory(appP ath+propertyIdL ocal+"/thumbnails");
propertyPath = Server.MapPath( "../photos/"+propertyIdLoc al+"/");
thumbnailPath = Server.MapPath( "../photos/"+propertyIdLoc al+"/thumbnails/");
for (int i=0; i<Request.Files .Count; i++) {
objFile = Request.Files[i];
if (objFile.FileNa me != "") {
strFileName = objFile.FileNam e;
strFileName = strFileName.Sub string(strFileN ame.LastIndexOf ("\\")+1);
try {
objFile.SaveAs( propertyPath+st rFileName);
System.Drawing. Image image =
System.Drawing. Image.FromFile( propertyPath+st rFileName);
System.Drawing. Image thumbImage =
image.GetThumbn ailImage(Conver t.ToInt32(100), Convert.ToInt32 (75),null,IntPt r.Zero);
image.Dispose() ;
thumbImage.Save (thumbnailPath+ strFileName, ImageFormat.Jpe g);
iString = ""+i+"";
uploadArray[i] = strFileName;
strMessage+= "Uploaded: "+strFileName+" <br>";
}
catch (Exception err) {
strMessage+= "Failed uploading "+strFileName+" :
"+err.ToString( )+"<br>";
}
}
}
uploadPhoto1Loc al = uploadArray[0];
uploadPhoto2Loc al = uploadArray[1];
uploadPhoto3Loc al = uploadArray[2];
uploadPhoto4Loc al = uploadArray[3];
uploadPhoto5Loc al = uploadArray[4];
uploadPhoto6Loc al = uploadArray[5];
MC_propertyPhot o1Hidden.Text = uploadPhoto1Loc al;
MC_propertyPhot o2Hidden.Text = uploadPhoto2Loc al;
MC_propertyPhot o3Hidden.Text = uploadPhoto3Loc al;
MC_propertyPhot o4Hidden.Text = uploadPhoto4Loc al;
MC_propertyPhot o5Hidden.Text = uploadPhoto5Loc al;
MC_propertyPhot o6Hidden.Text = uploadPhoto6Loc al;
return strMessage;
}
....
The page returns no errors and doens't perform the 'return strMessage;' as
it used to.
Thanks for your help.