Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm designing my web page i want store image location and then customer record i am doing photo studio management studio system image location not store...
namespace photoshops
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            onflbload(sender, e);
        }
        public void onflbload(object sender, EventArgs e)
        {
            string filename = Server.MapPath("~/photo") + FileUpload.PostedFile.FileName;
            FileUpload.PostedFile.SaveAs(filename);
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString =@"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
               
            try
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand("insert into tblphotosettings "
                 + "(BillNo,CustomerName,Address,StartDate,EndDate,Systemurl,Numberofcopies,Amount,Total ) values (@BillNo,@CustomerName,@Address,@StartDate,@EndDate,@Systemurl,@Numberofcopies,@Amount,@Total)", connection);
                cmd.Parameters.Add("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
                cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = TextBox2.Text;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
                cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value = Rdbsdate.SelectedDate;
                cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value = Rdbddate.SelectedDate;
                cmd.Parameters.Add("@Systemurl", SqlDbType.VarChar).Value = filename;
                cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value = TextBox7.Text;
                cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
                cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
                cmd.ExecuteNonQuery();
            }
            
            finally
            {
                connection.Close();
            }
        }
    }
}
my error
the page is run but choose a file window open how to store the image in photo folder my photo folder is on D: (in local)
Posted

Not sure if it will works for web application...just try

Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
 
Share this answer
 
Comments
vimal22 2 5-Apr-11 0:46am    
hiError

Error 1 The name 'Directory' does not exist in the current context C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\photoshops\photoshops\photosetting.aspx.cs 34 13 photoshops
Renat Khabibulin 5-Apr-11 2:26am    
add line

using System.IO;
vimal22 2 5-Apr-11 4:48am    
page is run i have on image desktop or D :, select the image in file upload control . save button click
the Error is file path is incorrect
vimal22 2 5-Apr-11 4:47am    
page is run i have on image desktop or D :, select the image in file upload control . save button click
the Error is file path is incorrect
not sure I understand your problem, but if you are looking for copying the file to your local directory,then probably this would help. Elaborate your question.
BinaryReader sr = new BinaryReader(this.FileUpload1.FileContent);
FileStream fs = new FileStream(@"C:\" + FileUpload1.FileName, FileMode.Create);
BinaryWriter sw = new BinaryWriter(fs);
//sw.Write(WriteLine(sr.ReadToEnd());
byte[] b = new byte[1024];
int index = 0;
int i;
while ((i = sr.Read(b, 0, 1024)) > 0)
{
    sw.Write(b);
    index += i;
}
//fs.Close();
sw.Flush();
sw.Close();
fs.Close();
 
Share this answer
 
Comments
vimal22 2 5-Apr-11 0:55am    
hi
Error 1 The type or namespace name 'BinaryReader' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\photoshops\photoshops\photosetting.aspx.cs 34 13 photoshops

Error 3 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\photoshops\photoshops\photosetting.aspx.cs 35 13 photoshops

Error 3 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\photoshops\photoshops\photosetting.aspx.cs 35 13 photoshops

Error 3 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'FileStream' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\photoshops\photoshops\photosetting.aspx.cs 35 13 photoshops
Renat Khabibulin 5-Apr-11 2:28am    
- The type or namespace name 'BinaryReader' could not be found .......
- The type or namespace name 'FileStream' could not be found ........

if namespace not found, place cursor on missed word and press Alt+Shift+F10. If it is available on any available namespace then VS will show popup with this namespace.
Since your question is not clearly asked I am assuming you want something like SaveDialog which can be accessible in winforms but not in web. You can check out these links how you can have your own Save As Dialog Box;

Link 1[^]

Link 2[^]
 
Share this answer
 
did you add using System.IO; namespace?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900