Maybe a simple question, but I really don't know what to do.
When I submit a file through a form using <asp:FileUpload>, it works fine on my dev machine.
When I try to do the same on the server, it gives me the error below. The error does not help me at all, because I don’t even have this function in my code (CaptureCollection), and I don’t have a variable named "i". So right now, I really don't know.
Is this a matter of rights on the server (I don’t think so because I give all possible rights and the error still exists), this is something on my code (but it works on my dev .. machine). I can show more code if you need!
Mistake:
Server Error in '/' Application.
-------------------------------------------------- ------------------------------
Specified argument was out of the range of valid values.
Parameter name: i
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: i
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: i]
System.Text.RegularExpressions.CaptureCollection.GetCapture (Int32 i) +5227599
System.Text.RegularExpressions.CaptureCollection.get_Item (Int32 i) +4
CreatePost.btnFinish_Click (Object sender, EventArgs e) +143
System.EventHandler.Invoke (Object sender, EventArgs e) +0
System.Web.UI.WebControls.Button.OnClick (EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent (String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent (NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
, . , , . dev, prod?
protected void btnFinish_Click(object sender, EventArgs e)
{
string file = "";
string csFinalPath = "";
if (uploadPhoto.HasFile)
{
string filepath = uploadPhoto.PostedFile.FileName;
string pat = @"\\(?:.+)\\(.+)\.(.+)";
Regex r = new Regex(pat);
Match m = r.Match(filepath);
string file_ext = m.Groups[2].Captures[0].ToString();
string filename = m.Groups[1].Captures[0].ToString();
file = filename + "." + file_ext;
uploadPhoto.PostedFile.SaveAs(Server.MapPath(".\\upload\\") + file);
ThumbnailGenerator thumbGenerator = new ThumbnailGenerator();
if (thumbGenerator.GetThumbnail(Server.MapPath(".\\upload\\") + file,
Server.MapPath(".\\upload\\thumb\\") + "Thumb" + file))
{
csFinalPath = "./upload/thumb/" + "Thumb" + file;
}
else
{
}
}
else
{
csFinalPath = "./images/no_image.gif";
}
m_database.InsertPost(Convert.ToInt32(Session["ID"].ToString()),
Convert.ToInt32(ddlCategory.SelectedValue),
m_nType,
txtLink.Text,
txtTitreFR.Text,
txtTitreEN.Text,
txtDescriptionFR.Text,
txtDescriptionEN.Text,
csFinalPath,
"",
"");
panelLink.Visible = false;
panelResult.Visible = true;
}