Alans Banner
+ Reply to Thread
Results 1 to 8 of 8

Thread: upload the image

  1. #1

    upload the image

    Can some one tell me how to upload the iamge int the webpage and the show it in datagrid view and also 2 images in one row.?

  2. .
  3. #2

    at first put the fili upload control then write the above code:
    dim s as string
    s=server.mappath("image")+fileupload1.filename
    fileupload1.saveas(s)
    image1.imageurl=s
    the above code help you

  4. .
  5. #3

    Quote Originally Posted by Amar View Post
    Can some one tell me how to upload the iamge int the webpage and the show it in datagrid view and also 2 images in one row.?
    hey you can upload image by this....
    fileupload1.saveas(str) (str is your string in which you assign the path of the image...)
    image1.imageurl = str
    here is the main steps for doing that...
    hope it helps you.......

  6. .
  7. #4

    this is a trditional way that all have posted but we can also use the image data type in the db server. It accepts byte value of the image. This can be used with javascript on the client side to read the byte values and then passing into the page control to the database.

  8. .
  9. #5

    This code will help you:
    private void Button1_Click(object sender, System.EventArgs e)
    {
    //It verifies if the archive exists

    if (Upload.PostedFile != null)
    {
    //To create a PostedFile

    HttpPostedFile File = Upload.PostedFile;

    //Create byte Array with file len

    byte[] Data = new Byte[File.ContentLength];
    //force the control to load data in array

    File.InputStream.Read(Data,0,File.ContentLength);

    int i = 0;

    //Dysplay array data in textbox

    for (i=0;i<Data.Length;i++)
    {
    TextBox1.Text += Data[i].ToString();
    }

    //Create procedure parameter

    object[] obj = new object[1];

    obj[0] = Data;

    //Execute the procedure with Microsoft.ApplicationBlocks.Data

    //Simple procedure

    /*CREATE PROCEDURE sp_img(@img image) AS

    insert into tb_img values(@img)*/

    //record data

    SqlHelper.ExecuteNonQuery(connectionString,"sp_img ",obj);

    }
    }

    private void Button2_Click(object sender, System.EventArgs e)
    {
    //Bind data to your grid

    //more details consulting

    //Working DataGrid TemplateColumns and Bind this Columns

    DataSet ds = SqlHelper.ExecuteDataset(connectionString,
    "sp_load_img",null);
    grid.DataSource = ds.Tables[0].DefaultView;
    grid.ObjectName = "Image1";
    grid.FieldName = "img";
    grid.Editable = false;
    grid.DataBind();
    grid.DataBindObjects(grid,ds,0,grid.PageSize);

    int i =0;

    for (i=0;i<ds.Tables[0].Rows.Count;i++)
    {
    //test your bitmap is valid

    //Demonstration

    byte[] bits = (byte[]) ds.Tables[0].Rows[i]
    ["img"];
    MemoryStream memorybits = new MemoryStream(bits);
    Bitmap bitmap = new Bitmap(memorybits);
    }


    }

    private void grid_PageIndexChanged(object source,
    System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
    {
    //Page your grid

    //Bind data to your grid

    //more details consulting

    //Working DataGrid TemplateColumns and Bind this Columns

    grid.CurrentPageIndex =e.NewPageIndex;
    DataSet ds = SqlHelper.ExecuteDataset(connectionString,
    "sp_load_img",null);
    grid.DataSource = ds.Tables[0].DefaultView;
    grid.ObjectName = "Image1";
    grid.FieldName = "img";
    grid.Editable = false;
    grid.DataBind();
    grid.DataBindObjects(grid,ds,e.NewPageIndex,grid.P ageSize);

    }
    }

  10. .
  11. #6

    I know how to upload.
    File Upload control is given to upload file.
    You can use it and filter out for image and make a folder IMAGE in your project give it as a path for storing image.

  12. .
  13. #7

    For uploading image you can use

    Fileupload1.postedfile.saveas(Server.Mappath(".\\i mages\\"+filename) to save the file

    where fileupload1 is the component name of file field

  14. .
  15. #8

    I think so do not know whether the correct.

    Use file upload control and save the images to the folder in your website

    eg

    if (fileImage.HasFile)
    {
    if (fileImage.PostedFile.ContentLength < 1048576)
    {
    String str = Guid.NewGuid().ToString();
    string a = str;
    str = Server.MapPath("~/Images/ImageGallery/") + str;
    fileImage.SaveAs(str + ".jpg");
    BllSodhis.Utility.GenerateThumb(str + "_Thumb.jpg", str + ".jpg", 100, 150);
    _objProperty.ImagePath = a;
    }

    }

    here fileImage is file upload control

  16. .
+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Convert image to a PDF
    By Kay in forum Graphics Forum
    Replies: 9
    Last Post: 08-02-2009, 04:59 AM
  2. Image alts
    By ankur0412 in forum SEO Forum
    Replies: 15
    Last Post: 08-01-2009, 09:07 AM
  3. Image uploader needed
    By nikon in forum Graphics
    Replies: 3
    Last Post: 07-30-2009, 09:25 AM
  4. Google Image Trick
    By Handsome in forum Google
    Replies: 17
    Last Post: 05-01-2009, 11:04 AM
  5. I want to upload an image on the web
    By Amar in forum Design and Development
    Replies: 1
    Last Post: 04-28-2009, 06:01 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
profitable webmaster resources
© 2010, vBulletin Solutions, Inc. All Rights Reserved. All designated trademarks and brands are the property of their respective owners. Use of this Website constitutes acceptance of our Terms and Conditions and Privacy Policy.

 

Content Relevant URLs by vBSEO