Hi everyone, maybe a simple question but I really don't know what to do.
When I submit a file through a form using , it works perfectly on my dev machine.
When I try the same thing on the server, it gives me the error below. The error doesn't help me at all because I don't even have this function in my code (CaptureCollection) and I don't have a variable called "i". So right now, I really don't know... Is this a question of right on the server (I don't think so because I give all the rights possible and the error is still there), is it something on my code (but it work on my dev machine...). I can show more code if you need!
Please help me:
The error:
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
EDIT - EDIT -EDIT
Here is the code that does the uploading. And maybe you are right with the regex... But why is it working on dev and not on 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);
//run
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;
//save the file to the server
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
{
//TODO: Do an error message!!!
}
}
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;
}