File upload using uploadcontrol

Posted by Santosh.Choudhury under ASP.NET on 7/1/2012 | Points: 10 | Views : 1173 | Status : [Member] | Replies : 7
I want to upload files using fileupload control .all files are shown in image control.if upload file is image then its ok.if the upload file is doc ,pdf then i want to show the content of the word and pdf file in image control..please help as soon as posible




Responses

Posted by: Johnbhatt on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
Check this link

http://www.dotnetfunda.com/codes/code2727-file-upload-control-with-file-type-filter.aspx

I have posted sample there with sample few days ago.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh.Choudhury on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
here there is no code for doc and pdf file.i want to show all file in image control.

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
protected void UploadButton_Click(object sender, EventArgs e)
{
if(FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
StatusLabel.Text = "Upload status: File uploaded!";
}
catch(Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh.Choudhury on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
yes all file is uploaded but i want to show the uploaded file in image controller.if doc file is uploaded then all the contents of the file display as like image.

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 11/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Santosh,
In Source:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table>
<tr><td><asp:Label ID="Label1" runat="server" Text=""></asp:Label></td></tr>
<tr><td><asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="Upload" runat="server" Text="Upload" OnClick="Upload_Click" />
<asp:Image ID="ImageView" runat="server" /></td></tr>
<tr><td align="center">
<asp:Button ID="Button1" runat="server" Text="Process Data" OnClick="Button1_Click" /></td></tr>
</table>
</div>
</form>
</body>
</html>

Backend code:

protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(MapPath("~/Image/" + FileUpload1.FileName));
System.Drawing.Image img1 = System.Drawing.Image.FromFile(
MapPath("~/image/") + FileUpload1.FileName);
ImageView.ImageUrl = "~/Image/" + FileUpload1.FileName;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
Label1.Text = "Data Processed Successfully";
}

Thanks & Regards
Hari

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 11/12/2012 [Member] Starter | Points: 25

Up
0
Down
Please Mark As Answer if u satisfy with my answer.It is useful to others

Thanks & Regards
Hari

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/30/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2011/05/image-upload.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Santosh.Choudhury, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response