Click here to Skip to main content
16,016,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi....

Can Anyone Answer...


how to store uploaded resume and its link into database by clicking that link i have to view uploaded resume....
Posted

C#
\\in aspx page
<asp:fileupload id="f1" runat="server" xmlns:asp="#unknown" />
\\in C# code page
        f1.SaveAs(Request.PhysicalApplicationPath + "/" + a.ToString() + "/" + f1.FileName);
        ss = a + "/" + f1.FileName;
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 7-Mar-12 7:13am    
Added code block
C#

my coding.....

C#
protected void b1_Click(object sender, EventArgs e)
   {
       a = drop1.SelectedValue.ToString() + drop2.SelectedValue.ToString();
       // Response.Write(a.ToString());
       f1.SaveAs(Request.PhysicalApplicationPath + "/" + a.ToString() + "/" + f1.FileName);
       ss = a + "/" + f1.FileName;
       _con.Open();
       SqlCommand _cmd = _con.CreateCommand();
       _cmd.CommandType = CommandType.StoredProcedure;
       _cmd.CommandText = "adminupload";
       _cmd.Parameters.Add("@stream", SqlDbType.VarChar).Value = drop1.SelectedItem.ToString();
       _cmd.Parameters.Add("@sem", SqlDbType.VarChar).Value = drop2.SelectedItem.ToString();
       _cmd.Parameters.Add("@subject", SqlDbType.VarChar).Value = TextBox3.Text;
       _cmd.Parameters.Add("@path", SqlDbType.VarChar).Value = ss.ToString();
       _cmd.Parameters.Add("@type", SqlDbType.VarChar).Value = DropDownList1.SelectedItem.ToString();
       _cmd.Parameters.Add("@filename", SqlDbType.VarChar).Value = f1.FileName.ToString();
       _cmd.Parameters.Add("@auther", SqlDbType.VarChar).Value = txtaut.ToString();

       _cmd.ExecuteNonQuery();
       _con.Close();


       _con.Open();
       SqlCommand _cmd1 = _con.CreateCommand();
       _cmd1.CommandType = CommandType.Text;
       _cmd1.CommandText = "select email from clientregi";
       _cmd1.ExecuteNonQuery();
       DataTable dt = new DataTable();
       SqlDataAdapter da = new SqlDataAdapter(_cmd1);
       da.Fill(dt);

    //   SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
    //   smtp.EnableSsl = true;
    //   smtp.UseDefaultCredentials = false;
    //   smtp.Credentials = new NetworkCredential("amit.andipara@gmail.com", "81181981");

       foreach (DataRow _dr in dt.Rows)
       {

           //(from,to,subject,body)
         //  MailMessage mail = new MailMessage("amit.andipara@gmail.com", _dr["email"].ToString(), "noble computer", "new materials updated");
        // smtp.Send(mail);
       }
       _con.Close();

       Response.Redirect("uploadfile.aspx");




   }

\\in aspx page...
XML
<center>
        <table border="2">
            <tr>
                <td style="height: 26px">
                    Enter stream
                </td>
                <td style="height: 26px">
                    <asp:DropDownList ID="drop1" runat="server" Width="129px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>bca</asp:ListItem>
                        <asp:ListItem>BSC.IT</asp:ListItem>
                        <asp:ListItem>mca</asp:ListItem>
                         <asp:ListItem>M.SC(IT &amp; CA)</asp:ListItem>
                         <asp:ListItem>P.G.D.C.A</asp:ListItem>
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td>
                    Enter sem</td>
                <td>
                    <asp:DropDownList ID="drop2" runat="server" Width="129px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                        <asp:ListItem>5</asp:ListItem>
                        <asp:ListItem>6</asp:ListItem>
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td>
                    Enter subject name</td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server" Width="129px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>
                    Enter path</td>
                <td>
                    <asp:FileUpload ID="f1" runat="server" /></td>
            </tr>
            <tr>
                <td>
                    Enter file type</td>
                <td>
                    <asp:DropDownList ID="DropDownList1" runat="server" Width="129px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>doc</asp:ListItem>
                        <asp:ListItem>pdf</asp:ListItem>
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td>
                    Enter Auther Name</td>
                <td>
                    <asp:TextBox ID="txtaut" runat="server" Width="129px"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="2">
                    <center>
                        <asp:Button ID="b1" runat="server" Text="save" OnClick="b1_Click" Width="87px" /></center>
                </td>
            </tr>
        </table>
    </center>




u just copy this code and just try it....i thik it' solve your problem
 
Share this answer
 
v3
Comments
Anuja Pawar Indore 7-Mar-12 7:13am    
Added code block
Sagar Tajpara 13-Jul-13 6:10am    
added code block means?
Anuja Pawar Indore 16-Jul-13 3:03am    
Added pre tag, so that code looks like c# code with indentation. Read the FAQ section.
Sagar Tajpara 16-Jul-13 7:09am    
ok i under stand.
i will add.
In this sample, I'm assuming that you are using a FileUpload button on the page. The code takes into account the fact that the user could upload a document with the same name as one that already exists.
C#
private void StoreUploadedFile()
{
  if (!fileUpload.HasFile)
  {
    return;
  }
  string path = Server.MapPath(string.Format("~/Resumes/{0}", Guid.NewGUID()));
  fileUpload.SaveAs(path);

  // Now, save these values to the database
  if (!SaveFileInformation(fileUpload.FileName, path))
  {
    // If we didn't save the file to the database, we have no link - so get rid
    // of the record and inform the user.
    File.Delete(path);
  }
}
I haven't included the code to save the file to the database - I'm assuming you know how to write that code yourself. There are a few things to note; you need to store the original filename, along with the path to the modified filename. Secondly, if you don't succeed in writing to the database, you should remove the file that was uploaded. Finally, this code relies on you having the appopriate privileges to write to the Resumes directory.

The sample I have provided has no error handling built into it. You should consider adding this to the code. What I have provided is a sample that I knocked up in the CP editor; it is not production ready code.
 
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