Now I tryed that, but it didn't work.
Under: filename a red line appears, and if I hold the mouse on that it writes: The name 'filename' does not exist in the current context.
and under ContentType a red line also appears witch says:
'System.web.ui.webcontrols.Fileupload' does not contain a definition for 'contenttype' and no extension method 'contenttype' accepting a first argument of type
'System.web.ui.webcontrols.Fileupload' could be found (are you missing a using directive or an assembly refference?)
Do you know how to fix it? please?
my whole code on my cs page looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (null != file.PostedFile)
{
try
{
if (file.ContentType.IndexOf("excel") >= 0)
file.SaveAs(Server.MapPath(@"\Upload\Excel\" + filename));
else if (file.ContentType.IndexOf("word") >= 0)
file.SaveAs(Server.MapPath(@"\Upload\Word\" + filename));
else
file.SaveAs(Server.MapPath(@"\Upload\Other\" + filename));
}
catch (Exception e)
{
}
}
}
}
Last edited by peter_budo; Apr 15th, 2009 at 7:57 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags. Keep It Spam-Free Do not spam, advertise, plug your website.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Offline 62 posts
since Dec 2008