Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
What should the position of an image file on the client system while installation of application. Where the image has to be displayed and printed in DataGridView report through PrintPage() event.
Posted
Comments
Sandeep Mewara 10-Mar-11 0:11am    
Not clear!
sairam.bhat 10-Mar-11 0:47am    
good question
sk saini 10-Mar-11 2:27am    
My question is regarding Windows application and I want to know that where should we store our image file (LOCATION) on client system through installation setup so that our report file may retrieve that image for printing.

For eg. Application data folder or program files folder etc. which location on client system is the best.


How to save client side image file to server side

XML
This code shold be copied in .aspx page:


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>File Upload Sample</title>

</head>

<body>

  <form id="form1" runat="server">

    <div>

      <table cellpadding="10" cellspacing="0" border="2" width="40%" height="100px">

        <tr>

        <td align="center" valign="top" style="padding-top:20px; background-color: #ffccff;">

           <asp:FileUpload ID="FileUpload1" runat="server" BackColor="#C0FFFF" BorderColor="Cyan" ForeColor="Green" /><br /><br />

           <asp:Button ID="Button1" runat="server" Onclick="Button_click" Text="Upload File" BackColor="#C0C0FF" BorderColor="#8080FF" BorderStyle="Outset" />

           <asp:RegularExpressionValidator  id="FileUpLoadValidator" runat="server"

            ErrorMessage="Upload Jpegs and Gifs only."

ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF)$"

            ControlToValidate="FileUpload1">

           </asp:RegularExpressionValidator>

         </td>

        </tr>

      </table>

    </div>

  </form>

</body>

</html>



The below code should be copied in the code behind file:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.IO;

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {}

    protected void Button_click(object sender, EventArgs e)

    {

        string str1 = FileUpload1.PostedFile.FileName;

        string str2 = Path.GetFileName(str1);

        string str3 = @"d:/puru/photo";  //give the path where you want to upload the file.

        FileUpload1.PostedFile.SaveAs(Path.Combine(str3, str2));

    }

}
 
Share this answer
 
Comments
amitkarnik2211 10-Mar-11 2:22am    
good Ans
You just answered your own question, place all the images in application folder, use can use images asfolder name. The same will be deployed when the setup is runned on the client system
 
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