locked
how can we upload a pic RRS feed

  • Question

  • User-779624372 posted

    How can we upload a pic in Insert and Update template generated by Linq to Sql Dynamic data App?

    Thursday, August 23, 2012 3:27 PM

Answers

  • User3866881 posted

    How can we upload a pic in Insert and Update template generated by Linq to Sql Dynamic data App?

    Hi,

    For upload a pic into the database in DD, I think you can have a look at this sample:

    http://csharpbits.notaclue.net/2008/07/dynamic-data-fileimageedit.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 25, 2012 5:36 AM
  • User2089281372 posted

    Its better to save image in File System then to save it in the database,So to do that :

    1- Add "FileUpload" in your upload.aspx an label (_msg.text) and a button

    2- in your upload.aspx.cs add this code:

            // Check to see if a file was actually selected
            if (uploadFile.PostedFile != null && uploadFile.PostedFile.ContentLength > 0)
            {
    
                // Get the filename and folder to write to
                string fileName = Path.GetFileName(uploadFile.PostedFile.FileName);
    
                string folder = Server.MapPath("~/UPLOADED_downs/");
    
                // Ensure the folder exists
                Directory.CreateDirectory(folder);
    
                // Save the file to the folder
                uploadFile.PostedFile.SaveAs(Path.Combine(folder, fileName));
    
    
                try
                {
    
    
                    _msg.Text = "Success,images saved";
    
                    Response.Write("Uploaded: " + fileName);
                }
                catch
                {
                    _msg.Text = "Operation Failed!!!";
                }
            }
    



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 25, 2012 9:38 AM

All replies

  • User3866881 posted

    How can we upload a pic in Insert and Update template generated by Linq to Sql Dynamic data App?

    Hi,

    For upload a pic into the database in DD, I think you can have a look at this sample:

    http://csharpbits.notaclue.net/2008/07/dynamic-data-fileimageedit.html

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 25, 2012 5:36 AM
  • User-779624372 posted

    i browsed this link already but it did helped.. can you explain me step by step in you know it??

    thanks for your reply

    Saturday, August 25, 2012 9:22 AM
  • User2089281372 posted

    Its better to save image in File System then to save it in the database,So to do that :

    1- Add "FileUpload" in your upload.aspx an label (_msg.text) and a button

    2- in your upload.aspx.cs add this code:

            // Check to see if a file was actually selected
            if (uploadFile.PostedFile != null && uploadFile.PostedFile.ContentLength > 0)
            {
    
                // Get the filename and folder to write to
                string fileName = Path.GetFileName(uploadFile.PostedFile.FileName);
    
                string folder = Server.MapPath("~/UPLOADED_downs/");
    
                // Ensure the folder exists
                Directory.CreateDirectory(folder);
    
                // Save the file to the folder
                uploadFile.PostedFile.SaveAs(Path.Combine(folder, fileName));
    
    
                try
                {
    
    
                    _msg.Text = "Success,images saved";
    
                    Response.Write("Uploaded: " + fileName);
                }
                catch
                {
                    _msg.Text = "Operation Failed!!!";
                }
            }
    



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 25, 2012 9:38 AM
  • User3866881 posted

    Just define an FileUpLoad and the accept the path, and do saving……

    Tuesday, August 28, 2012 10:00 PM