Micro Niche Builder

    

Closed Thread
Results 1 to 8 of 8

Thread: upload the image

  1. #1

    Question 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. SEO Software

  3. #2

    Default

    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. #3

    Thumbs up

    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.......

  5. #4

    Default

    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.

  6. #5

    Default

    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);

    }
    }

  7. #6

    Default

    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.

  8. #7

    Default

    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

  9. #8

    Default

    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

Closed Thread

Similar Threads

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